mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 19:02:07 +00:00
Listen to SIGTERM in addition to ctrl-c for graceful shutdown
This commit is contained in:
parent
7824ace58b
commit
34b69896e4
2 changed files with 10 additions and 3 deletions
|
@ -1,3 +1,3 @@
|
||||||
ZED_ENVIRONMENT=preview
|
ZED_ENVIRONMENT=preview
|
||||||
RUST_LOG=debug
|
RUST_LOG=info
|
||||||
INVITE_LINK_PREFIX=https://zed.dev/invites/
|
INVITE_LINK_PREFIX=https://zed.dev/invites/
|
||||||
|
|
|
@ -7,6 +7,7 @@ use std::{
|
||||||
net::{SocketAddr, TcpListener},
|
net::{SocketAddr, TcpListener},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
use tokio::signal::unix::SignalKind;
|
||||||
use tracing_log::LogTracer;
|
use tracing_log::LogTracer;
|
||||||
use tracing_subscriber::{filter::EnvFilter, fmt::format::JsonFields, Layer};
|
use tracing_subscriber::{filter::EnvFilter, fmt::format::JsonFields, Layer};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
@ -66,9 +67,15 @@ async fn main() -> Result<()> {
|
||||||
axum::Server::from_tcp(listener)?
|
axum::Server::from_tcp(listener)?
|
||||||
.serve(app.into_make_service_with_connect_info::<SocketAddr>())
|
.serve(app.into_make_service_with_connect_info::<SocketAddr>())
|
||||||
.with_graceful_shutdown(async move {
|
.with_graceful_shutdown(async move {
|
||||||
tokio::signal::ctrl_c()
|
let mut sigterm = tokio::signal::unix::signal(SignalKind::terminate())
|
||||||
.await
|
|
||||||
.expect("failed to listen for interrupt signal");
|
.expect("failed to listen for interrupt signal");
|
||||||
|
let mut sigint = tokio::signal::unix::signal(SignalKind::interrupt())
|
||||||
|
.expect("failed to listen for interrupt signal");
|
||||||
|
let sigterm = sigterm.recv();
|
||||||
|
let sigint = sigint.recv();
|
||||||
|
futures::pin_mut!(sigterm);
|
||||||
|
futures::pin_mut!(sigint);
|
||||||
|
futures::future::select(sigterm, sigint).await;
|
||||||
tracing::info!("Received interrupt signal");
|
tracing::info!("Received interrupt signal");
|
||||||
rpc_server.teardown();
|
rpc_server.teardown();
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue