Skip to content

fix: clean up worker and run state on daemon shutdown#24

Merged
danielkov merged 1 commit intomainfrom
fix/worker-shutdown-cleanup
Feb 22, 2026
Merged

fix: clean up worker and run state on daemon shutdown#24
danielkov merged 1 commit intomainfrom
fix/worker-shutdown-cleanup

Conversation

@danielkov
Copy link
Copy Markdown
Collaborator

Summary

  • shutdown_all now marks workers as stopped and cancels active runs in the DB before exiting, matching what stop_worker already does for individual workers.

Daemon shutdown now cleans up worker and run state

Previously, when the granary daemon shut down (via granary daemon stop, signals, or any other reason), workers were signalled to stop but their database status was never updated. This left workers permanently marked as running in the global database with their active runs also stuck in running state.

On next daemon start, restore_workers would find these stale "running" workers and attempt to respawn them — potentially picking up orphaned runs from completely unrelated workspaces. Manually stopping individual workers worked correctly because stop_worker properly updated the DB, but the bulk shutdown_all path (used on daemon exit) skipped this cleanup entirely.

shutdown_all now mirrors the same cleanup that stop_worker does: after signalling and waiting for workers to finish, it marks each worker as stopped and cancels any active runs in the database.

✻ Clauded...

shutdown_all now updates worker DB status to stopped and cancels
active runs, preventing orphaned workers from being respawned on
next daemon start.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danielkov danielkov merged commit c2b5299 into main Feb 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant