Search code examples
ruby-on-railsdockersidekiq

Running Sidekiq inside Docker - Handle termination of Docker container?


I'm using Rails + Sidekiq + Docker. I plan to deploy my Sidekiq process inside a Docker container. My jobs are quite long-running and have unpredictable durations (basically it's executing a long-running query against the database - can be up to 10-15 mins)

When I kill my docker container (as part of a new deployment), how I can tell Sidekiq to gracefully stop so that no existing jobs are interrupted?

Has anyone faced similar situation before. If so, how do you work around this?


Solution

  • docker stop -t XX should send the TERM signal to tell Sidekiq to shutdown and wait XX seconds.

    You'll want to extend Sidekiq's hard timeout too with sidekiq -t XX.