sidekiq: terminate child processes at shutdown
Sidekiq jobs frequently spawn long-lived child processes to do work. In some circumstances, these can be reparented to init when sidekiq is terminated, leading to duplication of work and strange concurrency problems. This commit changes sidekiq so that, if run as a process group leader, it will forward `INT` and `TERM` signals to the whole process group. If the memory killer is active, it will also use the process group when resorting to `kill -9` to shut down. These changes mean that a naive `kill <pid-of-sidekiq>` will now do the right thing, killing any child processes spawned by sidekiq, as long as the process supervisor placed it in its own process group. If sidekiq isn't a process group leader, this new code is skipped.
显示
- changelogs/unreleased/40396-sidekiq-in-process-group.yml 5 个添加, 0 个删除changelogs/unreleased/40396-sidekiq-in-process-group.yml
- config/initializers/sidekiq.rb 3 个添加, 0 个删除config/initializers/sidekiq.rb
- doc/administration/operations/sidekiq_memory_killer.md 5 个添加, 0 个删除doc/administration/operations/sidekiq_memory_killer.md
- lib/gitlab/sidekiq_middleware/memory_killer.rb 15 个添加, 2 个删除lib/gitlab/sidekiq_middleware/memory_killer.rb
- lib/gitlab/sidekiq_signals.rb 42 个添加, 0 个删除lib/gitlab/sidekiq_signals.rb
- spec/lib/gitlab/sidekiq_middleware/memory_killer_spec.rb 12 个添加, 1 个删除spec/lib/gitlab/sidekiq_middleware/memory_killer_spec.rb
- spec/lib/gitlab/sidekiq_signals_spec.rb 69 个添加, 0 个删除spec/lib/gitlab/sidekiq_signals_spec.rb
lib/gitlab/sidekiq_signals.rb
0 → 100644
spec/lib/gitlab/sidekiq_signals_spec.rb
0 → 100644
想要评论请 注册 或 登录