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
10
Cargo.lock
generated
10
Cargo.lock
generated
@ -2684,6 +2684,15 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signature"
|
||||
version = "2.2.0"
|
||||
@ -3164,6 +3173,7 @@ dependencies = [
|
||||
"mio",
|
||||
"num_cpus",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2 0.5.7",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.48.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
FROM docker.io/rust:1-alpine3.20 AS builder
|
||||
|
||||
RUN mkdir /tmp/tmp
|
||||
RUN mkdir /db
|
||||
RUN echo "hesinde:x:2222:2222:Linux User,,,:/:/app" > /passwd
|
||||
|
||||
RUN apk --no-cache add \
|
||||
@ -20,10 +20,10 @@ FROM scratch
|
||||
|
||||
COPY --from=builder /passwd /etc/passwd
|
||||
COPY --from=builder /app /app
|
||||
COPY --from=builder --chown=2222: /tmp/tmp /tmp
|
||||
COPY --from=builder --chown=2222: /db /db
|
||||
|
||||
USER hesinde
|
||||
|
||||
CMD ["/app", "--address", "[::]:3000"]
|
||||
|
||||
ENTRYPOINT ["/app", "--address", "[::]:3000"]
|
||||
EXPOSE 3000
|
||||
VOLUME ["/db"]
|
||||
|
@ -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…
Reference in New Issue
Block a user