[PR #493] [MERGED] refactor: complete graceful shutdown implementation and add service runner #770

Closed
opened 2025-10-09 16:56:52 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/pocket-id/pocket-id/pull/493
Author: @ItalyPaleAle
Created: 4/29/2025
Status: Merged
Merged: 5/4/2025
Merged by: @stonith404

Base: mainHead: graceful-shutdown-pt2


📝 Commits (9)

  • 3ac5806 refactor: complete graceful shutdown implementation
  • 2871c8d Merge branch 'main' into graceful-shutdown-pt2
  • e6fce54 Merge branch 'main' into graceful-shutdown-pt2
  • 5595662 Remove unnecessary code
  • e0bb454 Refactor update GeoLite DB
  • 2f44694 Add scaffholding code for shutdown services
  • 7e0e950 ServiceRunner: add unit tests, do not stop all services when one returns
  • b385c32 Merge branch 'main' into graceful-shutdown-pt2
  • 7255803 Address review feedback

📊 Changes

13 files changed (+454 additions, -130 deletions)

View changed files

📝 backend/cmd/main.go (+6 -1)
📝 backend/internal/bootstrap/bootstrap.go (+49 -5)
📝 backend/internal/bootstrap/e2etest_router_bootstrap.go (+3 -3)
📝 backend/internal/bootstrap/router_bootstrap.go (+56 -92)
backend/internal/bootstrap/scheduler_bootstrap.go (+35 -0)
backend/internal/bootstrap/services_bootstrap.go (+51 -0)
backend/internal/job/geoloite_update_job.go (+45 -0)
📝 backend/internal/job/scheduler.go (+3 -1)
📝 backend/internal/service/app_config_service.go (+2 -2)
📝 backend/internal/service/email_service.go (+1 -1)
📝 backend/internal/service/geolite_service.go (+20 -25)
backend/internal/utils/servicerunner.go (+58 -0)
backend/internal/utils/servicerunner_test.go (+125 -0)

📄 Description

Completes the work started in #482 to support graceful shutdown.

  1. Introduces a ServiceRunner which manages long-running background services, running them until the context is canceled (and collecting errors)
  2. Refactored initBootstrap and the GeoLite service's Run method to implement the ServiceRunner's Service interface
  3. Moved the initialization of all "services" (not long-running) and the scheduler into their own function

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/pocket-id/pocket-id/pull/493 **Author:** [@ItalyPaleAle](https://github.com/ItalyPaleAle) **Created:** 4/29/2025 **Status:** ✅ Merged **Merged:** 5/4/2025 **Merged by:** [@stonith404](https://github.com/stonith404) **Base:** `main` ← **Head:** `graceful-shutdown-pt2` --- ### 📝 Commits (9) - [`3ac5806`](https://github.com/pocket-id/pocket-id/commit/3ac5806ec17217e2fae81464052aef679b2b4cf2) refactor: complete graceful shutdown implementation - [`2871c8d`](https://github.com/pocket-id/pocket-id/commit/2871c8df4142e730da01dd55e93bafc02face817) Merge branch 'main' into graceful-shutdown-pt2 - [`e6fce54`](https://github.com/pocket-id/pocket-id/commit/e6fce54f5e473121f5890e2e444f1a1900801187) Merge branch 'main' into graceful-shutdown-pt2 - [`5595662`](https://github.com/pocket-id/pocket-id/commit/5595662aa7f5d74e16919a93323abc888b580a9e) Remove unnecessary code - [`e0bb454`](https://github.com/pocket-id/pocket-id/commit/e0bb454d5472e5f6f5e86de2b878460b321ad281) Refactor update GeoLite DB - [`2f44694`](https://github.com/pocket-id/pocket-id/commit/2f4469442945eb88ca40e366524166b7d5755139) Add scaffholding code for shutdown services - [`7e0e950`](https://github.com/pocket-id/pocket-id/commit/7e0e9508bffee93c097d288344bb4eaf56388bf2) ServiceRunner: add unit tests, do not stop all services when one returns - [`b385c32`](https://github.com/pocket-id/pocket-id/commit/b385c3287bad389963814f8b70359845155df252) Merge branch 'main' into graceful-shutdown-pt2 - [`7255803`](https://github.com/pocket-id/pocket-id/commit/7255803a4768c0b0447774c7c959924b05b8d0d4) Address review feedback ### 📊 Changes **13 files changed** (+454 additions, -130 deletions) <details> <summary>View changed files</summary> 📝 `backend/cmd/main.go` (+6 -1) 📝 `backend/internal/bootstrap/bootstrap.go` (+49 -5) 📝 `backend/internal/bootstrap/e2etest_router_bootstrap.go` (+3 -3) 📝 `backend/internal/bootstrap/router_bootstrap.go` (+56 -92) ➕ `backend/internal/bootstrap/scheduler_bootstrap.go` (+35 -0) ➕ `backend/internal/bootstrap/services_bootstrap.go` (+51 -0) ➕ `backend/internal/job/geoloite_update_job.go` (+45 -0) 📝 `backend/internal/job/scheduler.go` (+3 -1) 📝 `backend/internal/service/app_config_service.go` (+2 -2) 📝 `backend/internal/service/email_service.go` (+1 -1) 📝 `backend/internal/service/geolite_service.go` (+20 -25) ➕ `backend/internal/utils/servicerunner.go` (+58 -0) ➕ `backend/internal/utils/servicerunner_test.go` (+125 -0) </details> ### 📄 Description Completes the work started in #482 to support graceful shutdown. 1. Introduces a ServiceRunner which manages long-running background services, running them until the context is canceled (and collecting errors) 2. Refactored `initBootstrap` and the GeoLite service's Run method to implement the ServiceRunner's Service interface 3. Moved the initialization of all "services" (not long-running) and the scheduler into their own function --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-09 16:56:53 +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-2#770