diff options
| author | Ben Sima <ben@bsima.me> | 2025-09-05 14:56:37 -0400 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-09-05 14:56:37 -0400 |
| commit | c7eedaa2ac2b550d1726b4b004ed27b4c29e7ea9 (patch) | |
| tree | c8d525250188db5d62747e8f3b210101d0ec3c73 /Biz/PodcastItLater/Worker.nix | |
| parent | 7a4184e9367df0010140134c646121b84c7c4731 (diff) | |
Implement Graceful Shutdown for Worker Process
This commit adds robust shutdown handling for the PodcastItLater
worker process. Key improvements include:
- Introduce ShutdownHandler to manage graceful signal handling -
Add checkpoints in job processing to support interruption - Reset
stale jobs stuck in processing state on startup - Modify systemd
service configuration for better process management - Implement
interruptible sleep in main loop - Ensure current job can complete
or be reset during shutdown
Diffstat (limited to 'Biz/PodcastItLater/Worker.nix')
| -rw-r--r-- | Biz/PodcastItLater/Worker.nix | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Biz/PodcastItLater/Worker.nix b/Biz/PodcastItLater/Worker.nix index eafc95a..974a3ba 100644 --- a/Biz/PodcastItLater/Worker.nix +++ b/Biz/PodcastItLater/Worker.nix @@ -48,10 +48,15 @@ in { "DATA_DIR=${cfg.dataDir}" ]; EnvironmentFile = "/run/podcastitlater/worker-env"; - KillSignal = "INT"; + KillSignal = "TERM"; + KillMode = "mixed"; Type = "simple"; Restart = "always"; RestartSec = "10"; + # Give the worker time to finish current job + TimeoutStopSec = "300"; # 5 minutes + # Send SIGTERM first, then SIGKILL after timeout + SendSIGKILL = "yes"; }; }; }; |
