Line data Source code
1 : use std::num::NonZeroU32;
2 : use std::path::PathBuf;
3 : use std::sync::Arc;
4 : use std::time::Duration;
5 :
6 : use anyhow::{Context, anyhow};
7 : use camino::Utf8PathBuf;
8 : use clap::Parser;
9 : use futures::future::OptionFuture;
10 : use http_utils::tls_certs::ReloadingCertificateResolver;
11 : use hyper0::Uri;
12 : use metrics::BuildInfo;
13 : use metrics::launch_timestamp::LaunchTimestamp;
14 : use reqwest::Certificate;
15 : use storage_controller::http::make_router;
16 : use storage_controller::metrics::preinitialize_metrics;
17 : use storage_controller::persistence::Persistence;
18 : use storage_controller::service::chaos_injector::ChaosInjector;
19 : use storage_controller::service::{
20 : Config, HEARTBEAT_INTERVAL_DEFAULT, LONG_RECONCILE_THRESHOLD_DEFAULT,
21 : MAX_OFFLINE_INTERVAL_DEFAULT, MAX_WARMING_UP_INTERVAL_DEFAULT,
22 : PRIORITY_RECONCILER_CONCURRENCY_DEFAULT, RECONCILER_CONCURRENCY_DEFAULT, Service,
23 : };
24 : use tokio::signal::unix::SignalKind;
25 : use tokio_util::sync::CancellationToken;
26 : use tracing::Instrument;
27 : use utils::auth::{JwtAuth, SwappableJwtAuth};
28 : use utils::logging::{self, LogFormat};
29 : use utils::sentry_init::init_sentry;
30 : use utils::{project_build_tag, project_git_version, tcp_listener};
31 :
32 : project_git_version!(GIT_VERSION);
33 : project_build_tag!(BUILD_TAG);
34 :
35 : #[global_allocator]
36 : static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
37 :
38 : /// Configure jemalloc to profile heap allocations by sampling stack traces every 2 MB (1 << 21).
39 : /// This adds roughly 3% overhead for allocations on average, which is acceptable considering
40 : /// performance-sensitive code will avoid allocations as far as possible anyway.
41 : #[allow(non_upper_case_globals)]
42 : #[unsafe(export_name = "malloc_conf")]
43 : pub static malloc_conf: &[u8] = b"prof:true,prof_active:true,lg_prof_sample:21\0";
44 :
45 : const DEFAULT_SSL_KEY_FILE: &str = "server.key";
46 : const DEFAULT_SSL_CERT_FILE: &str = "server.crt";
47 : const DEFAULT_SSL_CERT_RELOAD_PERIOD: &str = "60s";
48 :
49 : #[derive(Parser)]
50 : #[command(author, version, about, long_about = None)]
51 : #[command(arg_required_else_help(true))]
52 : #[clap(group(
53 : clap::ArgGroup::new("listen-addresses")
54 : .required(true)
55 : .multiple(true)
56 : .args(&["listen", "listen_https"]),
57 : ))]
58 : struct Cli {
59 : /// Host and port to listen HTTP on, like `127.0.0.1:1234`.
60 : /// At least one of ["listen", "listen_https"] should be specified.
61 : // TODO: Make this option dev-only when https is out everywhere.
62 : #[arg(short, long)]
63 : listen: Option<std::net::SocketAddr>,
64 : /// Host and port to listen HTTPS on, like `127.0.0.1:1234`.
65 : /// At least one of ["listen", "listen_https"] should be specified.
66 : #[arg(long)]
67 : listen_https: Option<std::net::SocketAddr>,
68 :
69 : /// Public key for JWT authentication of clients
70 : #[arg(long)]
71 : public_key: Option<String>,
72 :
73 : /// Token for authenticating this service with the pageservers it controls
74 : #[arg(long)]
75 : jwt_token: Option<String>,
76 :
77 : /// Token for authenticating this service with the safekeepers it controls
78 : #[arg(long)]
79 : safekeeper_jwt_token: Option<String>,
80 :
81 : /// Token for authenticating this service with the control plane, when calling
82 : /// the compute notification endpoint
83 : #[arg(long)]
84 : control_plane_jwt_token: Option<String>,
85 :
86 : #[arg(long)]
87 : peer_jwt_token: Option<String>,
88 :
89 : /// URL to control plane storage API prefix
90 : #[arg(long)]
91 : control_plane_url: Option<String>,
92 :
93 : /// URL to connect to postgres, like postgresql://localhost:1234/storage_controller
94 : #[arg(long)]
95 : database_url: Option<String>,
96 :
97 : /// Flag to enable dev mode, which permits running without auth
98 : #[arg(long, default_value = "false")]
99 0 : dev: bool,
100 :
101 : /// Grace period before marking unresponsive pageserver offline
102 : #[arg(long)]
103 : max_offline_interval: Option<humantime::Duration>,
104 :
105 : /// More tolerant grace period before marking unresponsive pagserver offline used
106 : /// around pageserver restarts
107 : #[arg(long)]
108 : max_warming_up_interval: Option<humantime::Duration>,
109 :
110 : /// Size threshold for automatically splitting shards (disabled by default)
111 : #[arg(long)]
112 : split_threshold: Option<u64>,
113 :
114 : /// Maximum number of shards during autosplits. 0 disables autosplits. Defaults
115 : /// to 16 as a safety to avoid too many shards by accident.
116 : #[arg(long, default_value = "16")]
117 0 : max_split_shards: u8,
118 :
119 : /// Size threshold for initial shard splits of unsharded tenants. 0 disables initial splits.
120 : #[arg(long)]
121 : initial_split_threshold: Option<u64>,
122 :
123 : /// Number of target shards for initial splits. 0 or 1 disables initial splits. Defaults to 2.
124 : #[arg(long, default_value = "2")]
125 0 : initial_split_shards: u8,
126 :
127 : /// Maximum number of normal-priority reconcilers that may run in parallel
128 : #[arg(long)]
129 : reconciler_concurrency: Option<usize>,
130 :
131 : /// Maximum number of high-priority reconcilers that may run in parallel
132 : #[arg(long)]
133 : priority_reconciler_concurrency: Option<usize>,
134 :
135 : /// Tenant API rate limit, as requests per second per tenant.
136 : #[arg(long, default_value = "10")]
137 0 : tenant_rate_limit: NonZeroU32,
138 :
139 : /// How long to wait for the initial database connection to be available.
140 : #[arg(long, default_value = "5s")]
141 0 : db_connect_timeout: humantime::Duration,
142 :
143 : #[arg(long, default_value = "false")]
144 0 : start_as_candidate: bool,
145 :
146 : // TODO: make this mandatory once the helm chart gets updated
147 : #[arg(long)]
148 : address_for_peers: Option<Uri>,
149 :
150 : /// `neon_local` sets this to the path of the neon_local repo dir.
151 : /// Only relevant for testing.
152 : // TODO: make `cfg(feature = "testing")`
153 : #[arg(long)]
154 : neon_local_repo_dir: Option<PathBuf>,
155 :
156 : /// Chaos testing: exercise tenant migrations
157 : #[arg(long)]
158 : chaos_interval: Option<humantime::Duration>,
159 :
160 : /// Chaos testing: exercise an immediate exit
161 : #[arg(long)]
162 : chaos_exit_crontab: Option<cron::Schedule>,
163 :
164 : /// Maximum acceptable lag for the secondary location while draining
165 : /// a pageserver
166 : #[arg(long)]
167 : max_secondary_lag_bytes: Option<u64>,
168 :
169 : /// Period with which to send heartbeats to registered nodes
170 : #[arg(long)]
171 : heartbeat_interval: Option<humantime::Duration>,
172 :
173 : #[arg(long)]
174 : long_reconcile_threshold: Option<humantime::Duration>,
175 :
176 : /// Flag to use https for requests to pageserver API.
177 : #[arg(long, default_value = "false")]
178 0 : use_https_pageserver_api: bool,
179 :
180 : // Whether to put timelines onto safekeepers
181 : #[arg(long, default_value = "false")]
182 0 : timelines_onto_safekeepers: bool,
183 :
184 : /// Flag to use https for requests to safekeeper API.
185 : #[arg(long, default_value = "false")]
186 0 : use_https_safekeeper_api: bool,
187 :
188 : /// Path to a file with certificate's private key for https API.
189 : #[arg(long, default_value = DEFAULT_SSL_KEY_FILE)]
190 0 : ssl_key_file: Utf8PathBuf,
191 : /// Path to a file with a X509 certificate for https API.
192 : #[arg(long, default_value = DEFAULT_SSL_CERT_FILE)]
193 0 : ssl_cert_file: Utf8PathBuf,
194 : /// Period to reload certificate and private key from files.
195 : #[arg(long, default_value = DEFAULT_SSL_CERT_RELOAD_PERIOD)]
196 0 : ssl_cert_reload_period: humantime::Duration,
197 : /// Trusted root CA certificates to use in https APIs.
198 : #[arg(long)]
199 : ssl_ca_file: Option<PathBuf>,
200 :
201 : /// Neon local specific flag. When set, ignore [`Cli::control_plane_url`] and deliver
202 : /// the compute notification directly (instead of via control plane).
203 : #[arg(long, default_value = "false")]
204 0 : use_local_compute_notifications: bool,
205 : }
206 :
207 : enum StrictMode {
208 : /// In strict mode, we will require that all secrets are loaded, i.e. security features
209 : /// may not be implicitly turned off by omitting secrets in the environment.
210 : Strict,
211 : /// In dev mode, secrets are optional, and omitting a particular secret will implicitly
212 : /// disable the auth related to it (e.g. no pageserver jwt key -> send unauthenticated
213 : /// requests, no public key -> don't authenticate incoming requests).
214 : Dev,
215 : }
216 :
217 : impl Default for StrictMode {
218 0 : fn default() -> Self {
219 0 : Self::Strict
220 0 : }
221 : }
222 :
223 : /// Secrets may either be provided on the command line (for testing), or loaded from AWS SecretManager: this
224 : /// type encapsulates the logic to decide which and do the loading.
225 : struct Secrets {
226 : database_url: String,
227 : public_key: Option<JwtAuth>,
228 : pageserver_jwt_token: Option<String>,
229 : safekeeper_jwt_token: Option<String>,
230 : control_plane_jwt_token: Option<String>,
231 : peer_jwt_token: Option<String>,
232 : }
233 :
234 : impl Secrets {
235 : const DATABASE_URL_ENV: &'static str = "DATABASE_URL";
236 : const PAGESERVER_JWT_TOKEN_ENV: &'static str = "PAGESERVER_JWT_TOKEN";
237 : const SAFEKEEPER_JWT_TOKEN_ENV: &'static str = "SAFEKEEPER_JWT_TOKEN";
238 : const CONTROL_PLANE_JWT_TOKEN_ENV: &'static str = "CONTROL_PLANE_JWT_TOKEN";
239 : const PEER_JWT_TOKEN_ENV: &'static str = "PEER_JWT_TOKEN";
240 : const PUBLIC_KEY_ENV: &'static str = "PUBLIC_KEY";
241 :
242 : /// Load secrets from, in order of preference:
243 : /// - CLI args if database URL is provided on the CLI
244 : /// - Environment variables if DATABASE_URL is set.
245 0 : async fn load(args: &Cli) -> anyhow::Result<Self> {
246 0 : let Some(database_url) = Self::load_secret(&args.database_url, Self::DATABASE_URL_ENV)
247 : else {
248 0 : anyhow::bail!(
249 0 : "Database URL is not set (set `--database-url`, or `DATABASE_URL` environment)"
250 0 : )
251 : };
252 :
253 0 : let public_key = match Self::load_secret(&args.public_key, Self::PUBLIC_KEY_ENV) {
254 0 : Some(v) => Some(JwtAuth::from_key(v).context("Loading public key")?),
255 0 : None => None,
256 : };
257 :
258 0 : let this = Self {
259 0 : database_url,
260 0 : public_key,
261 0 : pageserver_jwt_token: Self::load_secret(
262 0 : &args.jwt_token,
263 0 : Self::PAGESERVER_JWT_TOKEN_ENV,
264 0 : ),
265 0 : safekeeper_jwt_token: Self::load_secret(
266 0 : &args.safekeeper_jwt_token,
267 0 : Self::SAFEKEEPER_JWT_TOKEN_ENV,
268 0 : ),
269 0 : control_plane_jwt_token: Self::load_secret(
270 0 : &args.control_plane_jwt_token,
271 0 : Self::CONTROL_PLANE_JWT_TOKEN_ENV,
272 0 : ),
273 0 : peer_jwt_token: Self::load_secret(&args.peer_jwt_token, Self::PEER_JWT_TOKEN_ENV),
274 0 : };
275 0 :
276 0 : Ok(this)
277 0 : }
278 :
279 0 : fn load_secret(cli: &Option<String>, env_name: &str) -> Option<String> {
280 0 : if let Some(v) = cli {
281 0 : Some(v.clone())
282 : } else {
283 0 : std::env::var(env_name).ok()
284 : }
285 0 : }
286 : }
287 :
288 0 : fn main() -> anyhow::Result<()> {
289 0 : logging::init(
290 0 : LogFormat::Plain,
291 0 : logging::TracingErrorLayerEnablement::Disabled,
292 0 : logging::Output::Stdout,
293 0 : )?;
294 :
295 : // log using tracing so we don't get confused output by default hook writing to stderr
296 0 : utils::logging::replace_panic_hook_with_tracing_panic_hook().forget();
297 0 :
298 0 : let _sentry_guard = init_sentry(Some(GIT_VERSION.into()), &[]);
299 0 :
300 0 : let hook = std::panic::take_hook();
301 0 : std::panic::set_hook(Box::new(move |info| {
302 0 : // let sentry send a message (and flush)
303 0 : // and trace the error
304 0 : hook(info);
305 0 :
306 0 : std::process::exit(1);
307 0 : }));
308 0 :
309 0 : tokio::runtime::Builder::new_current_thread()
310 0 : // We use spawn_blocking for database operations, so require approximately
311 0 : // as many blocking threads as we will open database connections.
312 0 : .max_blocking_threads(Persistence::MAX_CONNECTIONS as usize)
313 0 : .enable_all()
314 0 : .build()
315 0 : .unwrap()
316 0 : .block_on(async_main())
317 0 : }
318 :
319 0 : async fn async_main() -> anyhow::Result<()> {
320 0 : let launch_ts = Box::leak(Box::new(LaunchTimestamp::generate()));
321 0 :
322 0 : preinitialize_metrics();
323 0 :
324 0 : let args = Cli::parse();
325 0 : tracing::info!(
326 0 : "version: {}, launch_timestamp: {}, build_tag {}",
327 0 : GIT_VERSION,
328 0 : launch_ts.to_string(),
329 : BUILD_TAG,
330 : );
331 :
332 0 : let build_info = BuildInfo {
333 0 : revision: GIT_VERSION,
334 0 : build_tag: BUILD_TAG,
335 0 : };
336 :
337 0 : let strict_mode = if args.dev {
338 0 : StrictMode::Dev
339 : } else {
340 0 : StrictMode::Strict
341 : };
342 :
343 0 : let secrets = Secrets::load(&args).await?;
344 :
345 : // Validate required secrets and arguments are provided in strict mode
346 0 : match strict_mode {
347 : StrictMode::Strict
348 0 : if (secrets.public_key.is_none()
349 0 : || secrets.pageserver_jwt_token.is_none()
350 0 : || secrets.control_plane_jwt_token.is_none()
351 0 : || secrets.safekeeper_jwt_token.is_none()) =>
352 0 : {
353 0 : // Production systems should always have secrets configured: if public_key was not set
354 0 : // then we would implicitly disable auth.
355 0 : anyhow::bail!(
356 0 : "Insecure config! One or more secrets is not set. This is only permitted in `--dev` mode"
357 0 : );
358 : }
359 0 : StrictMode::Strict if args.control_plane_url.is_none() => {
360 0 : // Production systems should always have a control plane URL set, to prevent falling
361 0 : // back to trying to use neon_local.
362 0 : anyhow::bail!(
363 0 : "`--control-plane-url` is not set: this is only permitted in `--dev` mode"
364 0 : );
365 : }
366 0 : StrictMode::Strict if args.use_local_compute_notifications => {
367 0 : anyhow::bail!("`--use-local-compute-notifications` is only permitted in `--dev` mode");
368 : }
369 : StrictMode::Strict => {
370 0 : tracing::info!("Starting in strict mode: configuration is OK.")
371 : }
372 : StrictMode::Dev => {
373 0 : tracing::warn!("Starting in dev mode: this may be an insecure configuration.")
374 : }
375 : }
376 :
377 0 : let ssl_ca_certs = match args.ssl_ca_file.as_ref() {
378 0 : Some(ssl_ca_file) => {
379 0 : tracing::info!("Using ssl root CA file: {ssl_ca_file:?}");
380 0 : let buf = tokio::fs::read(ssl_ca_file).await?;
381 0 : Certificate::from_pem_bundle(&buf)?
382 : }
383 0 : None => Vec::new(),
384 : };
385 :
386 0 : let config = Config {
387 0 : pageserver_jwt_token: secrets.pageserver_jwt_token,
388 0 : safekeeper_jwt_token: secrets.safekeeper_jwt_token,
389 0 : control_plane_jwt_token: secrets.control_plane_jwt_token,
390 0 : peer_jwt_token: secrets.peer_jwt_token,
391 0 : control_plane_url: args.control_plane_url,
392 0 : max_offline_interval: args
393 0 : .max_offline_interval
394 0 : .map(humantime::Duration::into)
395 0 : .unwrap_or(MAX_OFFLINE_INTERVAL_DEFAULT),
396 0 : max_warming_up_interval: args
397 0 : .max_warming_up_interval
398 0 : .map(humantime::Duration::into)
399 0 : .unwrap_or(MAX_WARMING_UP_INTERVAL_DEFAULT),
400 0 : reconciler_concurrency: args
401 0 : .reconciler_concurrency
402 0 : .unwrap_or(RECONCILER_CONCURRENCY_DEFAULT),
403 0 : priority_reconciler_concurrency: args
404 0 : .priority_reconciler_concurrency
405 0 : .unwrap_or(PRIORITY_RECONCILER_CONCURRENCY_DEFAULT),
406 0 : tenant_rate_limit: args.tenant_rate_limit,
407 0 : split_threshold: args.split_threshold,
408 0 : max_split_shards: args.max_split_shards,
409 0 : initial_split_threshold: args.initial_split_threshold,
410 0 : initial_split_shards: args.initial_split_shards,
411 0 : neon_local_repo_dir: args.neon_local_repo_dir,
412 0 : max_secondary_lag_bytes: args.max_secondary_lag_bytes,
413 0 : heartbeat_interval: args
414 0 : .heartbeat_interval
415 0 : .map(humantime::Duration::into)
416 0 : .unwrap_or(HEARTBEAT_INTERVAL_DEFAULT),
417 0 : long_reconcile_threshold: args
418 0 : .long_reconcile_threshold
419 0 : .map(humantime::Duration::into)
420 0 : .unwrap_or(LONG_RECONCILE_THRESHOLD_DEFAULT),
421 0 : address_for_peers: args.address_for_peers,
422 0 : start_as_candidate: args.start_as_candidate,
423 0 : use_https_pageserver_api: args.use_https_pageserver_api,
424 0 : use_https_safekeeper_api: args.use_https_safekeeper_api,
425 0 : ssl_ca_certs,
426 0 : timelines_onto_safekeepers: args.timelines_onto_safekeepers,
427 0 : use_local_compute_notifications: args.use_local_compute_notifications,
428 0 : };
429 0 :
430 0 : // Validate that we can connect to the database
431 0 : Persistence::await_connection(&secrets.database_url, args.db_connect_timeout.into()).await?;
432 :
433 0 : let persistence = Arc::new(Persistence::new(secrets.database_url).await);
434 :
435 0 : let service = Service::spawn(config, persistence.clone()).await?;
436 :
437 0 : let auth = secrets
438 0 : .public_key
439 0 : .map(|jwt_auth| Arc::new(SwappableJwtAuth::new(jwt_auth)));
440 0 : let router = make_router(service.clone(), auth, build_info)
441 0 : .build()
442 0 : .map_err(|err| anyhow!(err))?;
443 0 : let http_service =
444 0 : Arc::new(http_utils::RequestServiceBuilder::new(router).map_err(|err| anyhow!(err))?);
445 :
446 0 : let api_shutdown = CancellationToken::new();
447 :
448 : // Start HTTP server
449 0 : let http_server_task: OptionFuture<_> = match args.listen {
450 0 : Some(http_addr) => {
451 0 : let http_listener = tcp_listener::bind(http_addr)?;
452 0 : let http_server =
453 0 : http_utils::server::Server::new(Arc::clone(&http_service), http_listener, None)?;
454 :
455 0 : tracing::info!("Serving HTTP on {}", http_addr);
456 0 : Some(tokio::task::spawn(http_server.serve(api_shutdown.clone())))
457 : }
458 0 : None => None,
459 : }
460 0 : .into();
461 :
462 : // Start HTTPS server
463 0 : let https_server_task: OptionFuture<_> = match args.listen_https {
464 0 : Some(https_addr) => {
465 0 : let https_listener = tcp_listener::bind(https_addr)?;
466 :
467 0 : let resolver = ReloadingCertificateResolver::new(
468 0 : "main",
469 0 : &args.ssl_key_file,
470 0 : &args.ssl_cert_file,
471 0 : *args.ssl_cert_reload_period,
472 0 : )
473 0 : .await?;
474 :
475 0 : let server_config = rustls::ServerConfig::builder()
476 0 : .with_no_client_auth()
477 0 : .with_cert_resolver(resolver);
478 0 :
479 0 : let tls_acceptor = tokio_rustls::TlsAcceptor::from(Arc::new(server_config));
480 0 : let https_server =
481 0 : http_utils::server::Server::new(http_service, https_listener, Some(tls_acceptor))?;
482 :
483 0 : tracing::info!("Serving HTTPS on {}", https_addr);
484 0 : Some(tokio::task::spawn(https_server.serve(api_shutdown.clone())))
485 : }
486 0 : None => None,
487 : }
488 0 : .into();
489 0 :
490 0 : let chaos_task = args.chaos_interval.map(|interval| {
491 0 : let service = service.clone();
492 0 : let cancel = CancellationToken::new();
493 0 : let cancel_bg = cancel.clone();
494 0 : let chaos_exit_crontab = args.chaos_exit_crontab;
495 0 : (
496 0 : tokio::task::spawn(
497 0 : async move {
498 0 : let mut chaos_injector =
499 0 : ChaosInjector::new(service, interval.into(), chaos_exit_crontab);
500 0 : chaos_injector.run(cancel_bg).await
501 0 : }
502 0 : .instrument(tracing::info_span!("chaos_injector")),
503 : ),
504 0 : cancel,
505 0 : )
506 0 : });
507 :
508 : // Wait until we receive a signal
509 0 : let mut sigint = tokio::signal::unix::signal(SignalKind::interrupt())?;
510 0 : let mut sigquit = tokio::signal::unix::signal(SignalKind::quit())?;
511 0 : let mut sigterm = tokio::signal::unix::signal(SignalKind::terminate())?;
512 0 : tokio::pin!(http_server_task, https_server_task);
513 0 : tokio::select! {
514 0 : _ = sigint.recv() => {},
515 0 : _ = sigterm.recv() => {},
516 0 : _ = sigquit.recv() => {},
517 0 : Some(err) = &mut http_server_task => {
518 0 : panic!("HTTP server task failed: {err:#?}");
519 : }
520 0 : Some(err) = &mut https_server_task => {
521 0 : panic!("HTTPS server task failed: {err:#?}");
522 : }
523 : }
524 0 : tracing::info!("Terminating on signal");
525 :
526 : // Stop HTTP and HTTPS servers first, so that we don't have to service requests
527 : // while shutting down Service.
528 0 : api_shutdown.cancel();
529 0 :
530 0 : // If the deadline is exceeded, we will fall through and shut down the service anyway,
531 0 : // any request handlers in flight will experience cancellation & their clients will
532 0 : // see a torn connection.
533 0 : let deadline = tokio::time::Instant::now() + Duration::from_secs(5);
534 0 :
535 0 : match tokio::time::timeout_at(deadline, http_server_task).await {
536 0 : Ok(Some(Ok(_))) => tracing::info!("Joined HTTP server task"),
537 0 : Ok(Some(Err(e))) => tracing::error!("Error joining HTTP server task: {e}"),
538 0 : Ok(None) => {} // HTTP is disabled.
539 0 : Err(_) => tracing::warn!("Timed out joining HTTP server task"),
540 : }
541 :
542 0 : match tokio::time::timeout_at(deadline, https_server_task).await {
543 0 : Ok(Some(Ok(_))) => tracing::info!("Joined HTTPS server task"),
544 0 : Ok(Some(Err(e))) => tracing::error!("Error joining HTTPS server task: {e}"),
545 0 : Ok(None) => {} // HTTPS is disabled.
546 0 : Err(_) => tracing::warn!("Timed out joining HTTPS server task"),
547 : }
548 :
549 : // If we were injecting chaos, stop that so that we're not calling into Service while it shuts down
550 0 : if let Some((chaos_jh, chaos_cancel)) = chaos_task {
551 0 : chaos_cancel.cancel();
552 0 : chaos_jh.await.ok();
553 0 : }
554 :
555 0 : service.shutdown().await;
556 0 : tracing::info!("Service shutdown complete");
557 :
558 0 : std::process::exit(0);
559 0 : }
|