mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 14:53:00 +03:00
[PR #482] refactor: graceful shutdown for server #785
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/pocket-id/pocket-id/pull/482
State: closed
Merged: Yes
Initial work on graceful shutdown, for now focused on the Gin server.
Implements the graceful shutdown pattern, by capturing SIGINT or SIGTERM signals, and asking the Gin server to drain all active requests before shutting down. This makes it so requests aren't interrupted while in-flight, if possible.
Additionally, includes rudimental graceful shutdown for the job scheduler, although this is not complete yet (the app doesn't wait for the scheduler to be shut down before exiting).
As part of the work on the scheduler, there's now a single gocron scheduler created, instead of 4. This is useful because each gocron scheduler spawns its own set of goroutines in background.