bug: Server container does not handle SIGTERM gracefully #72

Closed
opened 2026-04-26 16:46:27 +00:00 by icub3d · 0 comments
Owner

Migrated from GitHub issue icub3d/decentcom#110
Original Author: @icub3d
Original Date: 2026-04-23T18:04:45Z


Bug: Server container does not handle SIGTERM gracefully

Overview

The decentcom-server Docker container does not respond to SIGTERM signals, causing docker stop to hang for 10 seconds before forcefully killing the process with SIGKILL. This prevents graceful shutdown of the database and other resources.

Background

In Docker, the process started by the ENTRYPOINT runs as PID 1. Standard Linux signals like SIGTERM are not handled by default in PID 1 unless the application explicitly traps them or an init process like tini is used to proxy signals. This was observed during the verification of PR #109.

Requirements

  • The server process should gracefully shut down within the Docker container when receiving SIGTERM.
  • docker stop should complete quickly (well under the 10-second default timeout).
  • Shutdown logs should be visible in the container output.

Design

API / Interface Changes

None.

Data Model Changes

None.

Component Changes

  • server/src/main.rs: May need to add signal handling logic.
  • Dockerfile: May need to be updated to include tini or equivalent.

Task List

  • Investigate current signal handling in server/src/main.rs.
  • Choose between application-level handling (tokio signals) or using tini in the Dockerfile.
  • Implement the chosen solution.
  • Verify the fix locally using docker stop.

Test List

  • Run the server in Docker: docker run -d --name shutdown-test decentcom-server.
  • Time the shutdown: time docker stop shutdown-test.
  • Verify docker stop completes in < 2 seconds.
  • Check logs for graceful shutdown messages (e.g., "shutting down", "connections closed").

Open Questions

  • Is it better to handle this in Rust (more portable across different container runtimes) or via tini (easier and handles zombie processes)?
**Migrated from GitHub issue icub3d/decentcom#110** **Original Author:** @icub3d **Original Date:** 2026-04-23T18:04:45Z --- # Bug: Server container does not handle SIGTERM gracefully ## Overview The `decentcom-server` Docker container does not respond to `SIGTERM` signals, causing `docker stop` to hang for 10 seconds before forcefully killing the process with `SIGKILL`. This prevents graceful shutdown of the database and other resources. ## Background In Docker, the process started by the `ENTRYPOINT` runs as PID 1. Standard Linux signals like `SIGTERM` are not handled by default in PID 1 unless the application explicitly traps them or an init process like `tini` is used to proxy signals. This was observed during the verification of PR #109. ## Requirements - [x] The server process should gracefully shut down within the Docker container when receiving `SIGTERM`. - [x] `docker stop` should complete quickly (well under the 10-second default timeout). - [x] Shutdown logs should be visible in the container output. ## Design ### API / Interface Changes None. ### Data Model Changes None. ### Component Changes - `server/src/main.rs`: May need to add signal handling logic. - `Dockerfile`: May need to be updated to include `tini` or equivalent. ## Task List - [x] Investigate current signal handling in `server/src/main.rs`. - [x] Choose between application-level handling (tokio signals) or using `tini` in the Dockerfile. - [x] Implement the chosen solution. - [ ] Verify the fix locally using `docker stop`. ## Test List - [ ] Run the server in Docker: `docker run -d --name shutdown-test decentcom-server`. - [ ] Time the shutdown: `time docker stop shutdown-test`. - [ ] Verify `docker stop` completes in < 2 seconds. - [ ] Check logs for graceful shutdown messages (e.g., "shutting down", "connections closed"). ## Open Questions - Is it better to handle this in Rust (more portable across different container runtimes) or via `tini` (easier and handles zombie processes)?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
icub3d/decentcom#72
No description provided.