- fix: when shutting down a docker container, the services would not deregister from consul correctly
This commit is contained in:
@@ -64,7 +64,7 @@ async fn handle_connection(stream: &mut TcpStream, pool: Arc<BufferPool>, auth_c
|
||||
|
||||
pool.release(buffer).await;
|
||||
}
|
||||
|
||||
|
||||
if let Some(state) = connection_service.get_connection(&connection_id) {
|
||||
let session_id = state.session_id.unwrap();
|
||||
let mut auth_client = auth_client.lock().await;
|
||||
@@ -148,8 +148,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
});
|
||||
|
||||
let mut sigterm_stream = signal::unix::signal(signal::unix::SignalKind::terminate())?;
|
||||
select! {
|
||||
_ = signal::ctrl_c() => {},
|
||||
_ = signal::ctrl_c() => {
|
||||
info!("Received SIGINT (Ctrl+C), shutting down...");
|
||||
},
|
||||
_ = sigterm_stream.recv() => {
|
||||
info!("Received SIGTERM, shutting down...");
|
||||
},
|
||||
}
|
||||
|
||||
consul_registration::deregister_service(&consul_url, service_id.as_str()).await.expect("");
|
||||
|
||||
Reference in New Issue
Block a user