[PR #85] [CLOSED] fix(daemon): shut down cleanly in docker #105

Closed
opened 2026-10-18 21:14:23 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/oikb/pull/85
Author: @hexsm
Created: 7/16/2026
Status: ❌ Closed

Base: main ← Head: feature/daemon-graceful-shutdown


📝 Commits (2)

  • 91fc930 fix(daemon): preserve uvicorn signal handling
  • 533d6c1 fix(daemon): stop syncs cooperatively on shutdown

📊 Changes

2 files changed (+75 additions, -10 deletions)

View changed files

📝 src/oikb/daemon.py (+47 -9)
📝 src/oikb/sync.py (+28 -1)

📄 Description

Summary

Fixes daemon shutdown so Docker restarts/stops do not wait for the 10s kill timeout.

The daemon now leaves SIGTERM/SIGINT handling to Uvicorn in server mode, stops the scheduler through FastAPI shutdown, and passes a cooperative shutdown signal into active sync runs.

What Changed

  • Preserve Uvicorn signal handling in server mode.
  • Keep scheduler-owned signal handling only for --no-server.
  • Stop the scheduler during FastAPI shutdown.
  • Add cooperative cancellation to run_sync.
  • Stop new cleanup, directory creation, and upload work once shutdown is requested.
  • Set a short Uvicorn graceful shutdown timeout as a fallback for blocking work.

Validation

  • compileall -f src/oikb/daemon.py src/oikb/sync.py
  • git diff --check
  • Local run_sync(..., should_stop=...) cancellation smoke test
  • Docker shutdown test: normal stop exits in ~1s
  • Docker shutdown test with blocked sync request exits before Docker's 10s kill timeout
  • Live Docker restart test confirmed working

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/oikb/pull/85 **Author:** [@hexsm](https://github.com/hexsm) **Created:** 7/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/daemon-graceful-shutdown` --- ### 📝 Commits (2) - [`91fc930`](https://github.com/open-webui/oikb/commit/91fc93051bed54b65c4148bbfce13246fbef6213) fix(daemon): preserve uvicorn signal handling - [`533d6c1`](https://github.com/open-webui/oikb/commit/533d6c1dce24153cc89e9a662cd136d25840dc98) fix(daemon): stop syncs cooperatively on shutdown ### 📊 Changes **2 files changed** (+75 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/oikb/daemon.py` (+47 -9) 📝 `src/oikb/sync.py` (+28 -1) </details> ### 📄 Description ## Summary Fixes daemon shutdown so Docker restarts/stops do not wait for the 10s kill timeout. The daemon now leaves SIGTERM/SIGINT handling to Uvicorn in server mode, stops the scheduler through FastAPI shutdown, and passes a cooperative shutdown signal into active sync runs. ## What Changed - Preserve Uvicorn signal handling in server mode. - Keep scheduler-owned signal handling only for `--no-server`. - Stop the scheduler during FastAPI shutdown. - Add cooperative cancellation to `run_sync`. - Stop new cleanup, directory creation, and upload work once shutdown is requested. - Set a short Uvicorn graceful shutdown timeout as a fallback for blocking work. ## Validation - `compileall -f src/oikb/daemon.py src/oikb/sync.py` - `git diff --check` - Local `run_sync(..., should_stop=...)` cancellation smoke test - Docker shutdown test: normal stop exits in ~1s - Docker shutdown test with blocked sync request exits before Docker's 10s kill timeout - Live Docker restart test confirmed working --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-18 21:14:23 +00:00
Sign in to join this conversation.
No labels
pull-request
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
open-webui/oikb#105
No description provided.