From 3ce75d1f0294115d60de2ca5efe64de080806a76 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Mon, 19 Jul 2021 11:55:39 +0200 Subject: [PATCH 1/2] apply fix --- src/main.rs | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 324a3ad..34489d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -185,7 +185,7 @@ async fn main() { std::env::set_var("CONDUIT_LOG_LEVEL", "off"); let raw_config = - Figment::from(rocket::Config::release_default()) + Figment::from(default_config()) .merge( Toml::file(Env::var("CONDUIT_CONFIG").expect( "The CONDUIT_CONFIG env var needs to be set. Example: /etc/conduit.toml", @@ -261,3 +261,32 @@ fn missing_token_catcher() -> Result<()> { fn bad_json_catcher() -> Result<()> { Err(Error::BadRequest(ErrorKind::BadJson, "Bad json.")) } + +fn default_config() -> rocket::Config { + let mut config = rocket::Config::release_default(); + + { + let mut shutdown = &mut config.shutdown; + + #[cfg(unix)] + { + use rocket::config::Sig; + + let signals = &mut shutdown.signals; + + signals.insert(Sig::Term); + signals.insert(Sig::Int); + } + + // Once shutdown is triggered, this is the amount of seconds before rocket + // will forcefully start shutting down connections, this gives enough time to /sync + // requests and the like (which havent gotten the memo, somehow) to still complete gracefully. + shutdown.grace = 35; + + // After the grace period, rocket starts shutting down connections, and waits at least this + // many seconds before forcefully shutting all of them down. + shutdown.mercy = 10; + } + + config +} From faa283d35b7771cec7f9ecaff13ca2960b4e49d5 Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Mon, 19 Jul 2021 13:44:53 +0200 Subject: [PATCH 2/2] review feedback --- src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 34489d3..f69bc48 100644 --- a/src/main.rs +++ b/src/main.rs @@ -272,10 +272,8 @@ fn default_config() -> rocket::Config { { use rocket::config::Sig; - let signals = &mut shutdown.signals; - - signals.insert(Sig::Term); - signals.insert(Sig::Int); + shutdown.signals.insert(Sig::Term); + shutdown.signals.insert(Sig::Int); } // Once shutdown is triggered, this is the amount of seconds before rocket