[PR #482] refactor: graceful shutdown for server #785

Closed
opened 2025-10-08 00:17:07 +03:00 by OVERLORD · 0 comments
Owner

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.

**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](https://www.freecodecamp.org/news/graceful-shutdowns-k8s-go/), 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.
OVERLORD added the pull-request label 2025-10-08 00:17:07 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-1#785