mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-27 02:45:27 +00:00
Merge branch 'fix-shutdown-period' into 'master'
Fix shutdown period See merge request famedly/conduit!131
This commit is contained in:
commit
59d538206f
29
src/main.rs
29
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,30 @@ 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;
|
||||
|
||||
shutdown.signals.insert(Sig::Term);
|
||||
shutdown.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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue