validation: listen for sigkill
This commit is contained in:
parent
c99608aaff
commit
22086e772c
10
validation/Cargo.lock
generated
10
validation/Cargo.lock
generated
@ -1925,6 +1925,15 @@ version = "1.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "signal-hook-registry"
|
||||||
|
version = "1.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signatory"
|
name = "signatory"
|
||||||
version = "0.27.1"
|
version = "0.27.1"
|
||||||
@ -2149,6 +2158,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
|
@ -16,5 +16,5 @@ rust-grpc = { version = "1.0.3", registry = "strafesnet" }
|
|||||||
serde = { version = "1.0.215", features = ["derive"] }
|
serde = { version = "1.0.215", features = ["derive"] }
|
||||||
serde_json = "1.0.133"
|
serde_json = "1.0.133"
|
||||||
siphasher = "1.0.1"
|
siphasher = "1.0.1"
|
||||||
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "fs"] }
|
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "fs", "signal"] }
|
||||||
tonic = "0.12.3"
|
tonic = "0.12.3"
|
||||||
|
@ -42,6 +42,9 @@ async fn main()->Result<(),StartupError>{
|
|||||||
let data_host=std::env::var("DATA_HOST").expect("DATA_HOST env required");
|
let data_host=std::env::var("DATA_HOST").expect("DATA_HOST env required");
|
||||||
let maps_grpc=crate::types::MapsServiceClient::connect(data_host).await.map_err(StartupError::GRPCConnect)?;
|
let maps_grpc=crate::types::MapsServiceClient::connect(data_host).await.map_err(StartupError::GRPCConnect)?;
|
||||||
|
|
||||||
|
// Create a signal listener for SIGTERM
|
||||||
|
let mut sig_term = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).expect("Failed to create SIGTERM signal listener");
|
||||||
|
|
||||||
// connect to nats
|
// connect to nats
|
||||||
let (publish_new,publish_fix,validator)=tokio::try_join!(
|
let (publish_new,publish_fix,validator)=tokio::try_join!(
|
||||||
publish_new::Publisher::new(stream.clone(),cookie_context.clone(),api.clone(),maps_grpc),
|
publish_new::Publisher::new(stream.clone(),cookie_context.clone(),api.clone(),maps_grpc),
|
||||||
@ -51,12 +54,12 @@ async fn main()->Result<(),StartupError>{
|
|||||||
validator::Validator::new(stream.clone(),cookie_context,api)
|
validator::Validator::new(stream.clone(),cookie_context,api)
|
||||||
).map_err(StartupError::NatsStartup)?;
|
).map_err(StartupError::NatsStartup)?;
|
||||||
|
|
||||||
// publisher threads
|
// nats consumer threads
|
||||||
tokio::spawn(publish_new.run());
|
tokio::spawn(publish_new.run());
|
||||||
tokio::spawn(publish_fix.run());
|
tokio::spawn(publish_fix.run());
|
||||||
|
tokio::spawn(validator.run());
|
||||||
|
|
||||||
// run validator on the main thread indefinitely
|
sig_term.recv().await;
|
||||||
validator.run().await;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user