spatecon / gitlab-review-bot

Observes and modifies Merge Requests by Review&Approve Policy. Daily Slack notifications included.
MIT License
49 stars 4 forks source link

Graceful shutdown #2

Closed spatecon closed 2 years ago

spatecon commented 2 years ago

The application should receive system SIGINT signal and start graceful shutdown process:

  1. Unschedule cron jobs
  2. ~Close all workers (for example, gitlab puller worker has Close() method)~
  3. ~Wait for 15 seconds till current jobs are done (or check for cron jobs are done if possible)~
  4. ~Cancel all contexts~
  5. ~Close database connection~
  6. ~Log that app gracefully stopped~

For this purpose app-wide context declared in internal/pkg/app should be passed to all clients and repository constructors. And then is should be used as parent context for context.WithTimeout.