Search code examples
ruby-on-railscapistranosidekiq

Rails/Capistrano: check if sidekiq is running on an EC2 instance


I'm using an EC2 instance for hosting a rails application. I'm deploying with capistrano and I had already included sidekiq and it's working fine. However, sometimes on deploy, and sometimes sporadically, sidekiq stops running and I don't notice until some tasks that use sidekiq doesn't run.

I could do something on deploy to check that, but if it stops to work eventually after deploy, that would still be a problem.

I would like to know what is the best way, in that scenario, to check periodically if sidekiq is running, and if not to, run it.

I thought of doing a bash script for that, but apparently, when I run sidekiq from command line, it creates another process with a different pid of the one launched by sidekiq... so I think it could get messy. Any help is appreciated. Thanks!


Solution

  • Learn and use systemd to manage the service.

    https://github.com/mperham/sidekiq/wiki/Deployment#running-your-own-process