File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,12 +70,19 @@ ENV STATIC_FILES_DIR=/app/static
7070ENV RUST_LOG=info,dynamight=debug
7171ENV DYNAMIGHT_CONFIG=/app/config/dynamight.toml
7272
73- # Expose port
73+ # Expose default port
7474EXPOSE 8080
7575
76- # Health check
76+ # Health check script (reads port from config file, falls back to 8080)
77+ COPY <<'EOF' /app/healthcheck.sh
78+ # !/bin/sh
79+ PORT=$(grep -E '^[[:space:]]*port[[:space:]]*=' /app/config/dynamight.toml 2>/dev/null | head -1 | tr -dc '0-9' )
80+ wget -qO /dev/null "http://127.0.0.1:${PORT:-8080}/api/system/health"
81+ EOF
82+ RUN chmod +x /app/healthcheck.sh
83+
7784HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
78- CMD wget -q --spider http://localhost:8080/api/system/health || exit 1
85+ CMD /app/healthcheck.sh
7986
8087# Run as root (required for mount operations)
8188ENTRYPOINT ["./dynamight" ]
Original file line number Diff line number Diff line change @@ -451,7 +451,29 @@ async fn main() -> anyhow::Result<()> {
451451 listener,
452452 app. into_make_service_with_connect_info :: < SocketAddr > ( ) ,
453453 )
454+ . with_graceful_shutdown ( shutdown_signal ( ) )
454455 . await ?;
455456
457+ tracing:: info!( "Server shut down gracefully" ) ;
456458 Ok ( ( ) )
457459}
460+
461+ async fn shutdown_signal ( ) {
462+ let ctrl_c = async {
463+ tokio:: signal:: ctrl_c ( )
464+ . await
465+ . expect ( "failed to install Ctrl+C handler" ) ;
466+ } ;
467+
468+ let terminate = async {
469+ tokio:: signal:: unix:: signal ( tokio:: signal:: unix:: SignalKind :: terminate ( ) )
470+ . expect ( "failed to install SIGTERM handler" )
471+ . recv ( )
472+ . await ;
473+ } ;
474+
475+ tokio:: select! {
476+ _ = ctrl_c => tracing:: info!( "Received Ctrl+C, shutting down..." ) ,
477+ _ = terminate => tracing:: info!( "Received SIGTERM, shutting down..." ) ,
478+ }
479+ }
You can’t perform that action at this time.
0 commit comments