shut down on ctrl+c
All checks were successful
Build Multiarch Container Image / call-reusable-workflow (push) Successful in 36m34s
All checks were successful
Build Multiarch Container Image / call-reusable-workflow (push) Successful in 36m34s
This commit is contained in:
parent
f568c9695b
commit
402b8e3a57
5 changed files with 28 additions and 9 deletions
|
@ -17,7 +17,7 @@ sea-orm = { workspace = true, features = ["with-time", "sqlx-sqlite", "sqlx-post
|
|||
serde = { workspace = true, features = ["derive"] }
|
||||
thiserror = "1.0.61"
|
||||
time = { workspace = true, features = ["macros", "serde", "formatting", "parsing" ] }
|
||||
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread"] }
|
||||
tokio = { version = "1.38.0", features = ["macros", "rt-multi-thread", "signal"] }
|
||||
tracing = "0.1.40"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||
uuid = { version = "1.10.0", features = ["v4", "fast-rng"] }
|
||||
|
|
|
@ -12,6 +12,8 @@ use poem::{
|
|||
};
|
||||
use poem_openapi::OpenApiService;
|
||||
use std::sync::Arc;
|
||||
use tokio::signal;
|
||||
use tracing::info;
|
||||
|
||||
pub mod api;
|
||||
pub mod app_state;
|
||||
|
@ -43,7 +45,13 @@ pub async fn run(args: &Config, db_url: &str) -> Result<()> {
|
|||
.data(app_state)
|
||||
.with(Tracing);
|
||||
|
||||
Ok(poem::Server::new(TcpListener::bind(&args.address))
|
||||
.run(app)
|
||||
.await?)
|
||||
let server = poem::Server::new(TcpListener::bind(&args.address)).run(app);
|
||||
|
||||
tokio::select! {
|
||||
_ = server => {},
|
||||
_ = signal::ctrl_c() => {
|
||||
info!("Received Ctrl+C, shutting down...");
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -15,8 +15,9 @@ async fn main() -> Result<()> {
|
|||
tracing_subscriber::fmt::init();
|
||||
|
||||
let args = Config::parse();
|
||||
println!("{}", args.allow_registration);
|
||||
println!("{}", args.db_connection);
|
||||
let db_url = read_db_url(&args.db_connection)?;
|
||||
println!("{db_url}");
|
||||
|
||||
hesinde_sync::run(&args, &db_url).await
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue