refactor: graceful shutdown for server #219

Closed
opened 2025-07-08 08:42:45 -04:00 by AtHeartEngineer · 0 comments

Originally created by @ItalyPaleAle on 4/25/2025

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.

*Originally created by @ItalyPaleAle on 4/25/2025* 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/pocket-id#219