mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 22:52:58 +03:00
[PR #482] [MERGED] refactor: graceful shutdown for server #778
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?
📋 Pull Request Information
Original PR: https://github.com/pocket-id/pocket-id/pull/482
Author: @ItalyPaleAle
Created: 4/25/2025
Status: ✅ Merged
Merged: 4/28/2025
Merged by: @stonith404
Base:
main← Head:graceful-server-shutdown📝 Commits (3)
58beec2refactor: graceful shutdown for server2c8c0aeLintac37aaaMerge branch 'main' into graceful-server-shutdown📊 Changes
10 files changed (+207 additions, -88 deletions)
View changed files
📝
backend/internal/bootstrap/application_images_bootstrap.go(+7 -3)📝
backend/internal/bootstrap/bootstrap.go(+3 -1)📝
backend/internal/bootstrap/router_bootstrap.go(+74 -13)📝
backend/internal/job/api_key_expiry_job.go(+2 -10)📝
backend/internal/job/db_cleanup_job.go(+9 -14)📝
backend/internal/job/file_cleanup_job.go(+2 -10)➖
backend/internal/job/job.go(+0 -29)📝
backend/internal/job/ldap_job.go(+6 -8)➕
backend/internal/job/scheduler.go(+64 -0)➕
backend/internal/utils/signals/signal.go(+40 -0)📄 Description
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.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.