Skip to content

Commit

Permalink
Remove ctrlc crate and some updates
Browse files Browse the repository at this point in the history
- Removed ctrlc crate and use the tokio provided ctrl_c function.
- Updated some crates.
  • Loading branch information
BlackDex committed Dec 10, 2022
1 parent b7c9a34 commit e524052
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 82 deletions.
119 changes: 48 additions & 71 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ dashmap = "5.4.0"

# Async futures
futures = "0.3.25"
tokio = { version = "1.22.0", features = ["rt-multi-thread", "fs", "io-util", "parking_lot", "time"] }
tokio = { version = "1.23.0", features = ["rt-multi-thread", "fs", "io-util", "parking_lot", "time", "signal"] }

# A generic serialization/deserialization framework
serde = { version = "1.0.148", features = ["derive"] }
serde = { version = "1.0.149", features = ["derive"] }
serde_json = "1.0.89"

# A safe, extensible ORM and Query builder
Expand All @@ -93,10 +93,10 @@ chrono-tz = "0.8.1"
time = "0.3.17"

# Job scheduler
job_scheduler_ng = "2.0.2"
job_scheduler_ng = "2.0.3"

# Data encoding library Hex/Base32/Base64
data-encoding = "2.3.2"
data-encoding = "2.3.3"

# JWT library
jsonwebtoken = "8.1.1"
Expand Down Expand Up @@ -136,7 +136,7 @@ cookie = "0.16.1"
cookie_store = "0.19.0"

# Used by U2F, JWT and Postgres
openssl = "0.10.43"
openssl = "0.10.44"

# CLI argument parsing
pico-args = "0.5.0"
Expand All @@ -145,9 +145,6 @@ pico-args = "0.5.0"
paste = "1.0.9"
governor = "0.5.1"

# Capture CTRL+C
ctrlc = { version = "3.2.3", features = ["termination"] }

# Check client versions for specific features.
semver = "1.0.14"

Expand Down
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,12 @@ async fn launch_rocket(pool: db::DbPool, extra_debug: bool) -> Result<(), Error>
.await?;

CONFIG.set_rocket_shutdown_handle(instance.shutdown());
ctrlc::set_handler(move || {

tokio::spawn(async move {
tokio::signal::ctrl_c().await.expect("Error setting Ctrl-C handler");
info!("Exiting vaultwarden!");
CONFIG.shutdown();
})
.expect("Error setting Ctrl-C handler");
});

let _ = instance.launch().await?;

Expand Down

0 comments on commit e524052

Please sign in to comment.