Skip to content

Commit

Permalink
fix: graceful shutdown in unix
Browse files Browse the repository at this point in the history
  • Loading branch information
ElaBosak233 committed Nov 15, 2024
1 parent 597e733 commit d15147a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 83 deletions.
32 changes: 0 additions & 32 deletions deploys/compose.dev.yml

This file was deleted.

42 changes: 0 additions & 42 deletions deploys/compose.yml

This file was deleted.

9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ async fn bootstrap() {

async fn shutdown_signal() {
let ctrl_c = async {
tokio::signal::ctrl_c().await.expect("Failed to install Ctrl+C handler");
tokio::signal::ctrl_c()
.await
.expect("Failed to install Ctrl+C handler");
};

#[cfg(unix)]
let terminate = async {
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate());
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
.expect("Failed to install signal handler")
.recv()
.await;
};

#[cfg(not(unix))]
Expand Down
10 changes: 3 additions & 7 deletions src/web/router/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use axum::{
middleware::from_fn,
response::IntoResponse,
Router,
};
use tower_http::{trace::TraceLayer};
use axum::{middleware::from_fn, response::IntoResponse, Router};
use tower_http::trace::TraceLayer;

use crate::{web::middleware};
use crate::web::middleware;

pub mod api;
pub mod metric;
Expand Down

0 comments on commit d15147a

Please sign in to comment.