handle ctrl+c in containers
This commit is contained in:
parent
fd7f551726
commit
fd942bb416
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -1511,6 +1511,15 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.11"
|
||||
@ -1679,6 +1688,7 @@ dependencies = [
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.48.0",
|
||||
|
@ -16,7 +16,7 @@ serde_with = "3.8.1"
|
||||
tera = "1.19.1"
|
||||
thiserror = { workspace = true }
|
||||
time = { workspace = true }
|
||||
tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] }
|
||||
tokio = { version = "1.37.0", features = ["signal", "rt-multi-thread", "macros"] }
|
||||
tokio-util = "0.7.11"
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = "0.3.18"
|
||||
|
@ -12,6 +12,8 @@ use poem::{
|
||||
Route, Server,
|
||||
};
|
||||
use rust_embed::RustEmbed;
|
||||
use tokio::signal;
|
||||
use tracing::info;
|
||||
|
||||
pub mod app_state;
|
||||
pub mod cli;
|
||||
@ -123,8 +125,15 @@ pub async fn run(config: Config) -> Result<(), std::io::Error> {
|
||||
.data(app_state)
|
||||
.with(Tracing);
|
||||
|
||||
Server::new(TcpListener::bind("[::]:3000"))
|
||||
let server = Server::new(TcpListener::bind("[::]:3000"))
|
||||
.name("cops-web")
|
||||
.run(app)
|
||||
.await
|
||||
.run(app);
|
||||
|
||||
tokio::select! {
|
||||
_ = server => {},
|
||||
_ = signal::ctrl_c() => {
|
||||
info!("Received Ctrl+C, shutting down...");
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user