Search code examples
ruby-on-railscapistranounicornsidekiq

How to supervise sidekiq and rails server processes?


What is the best way to manage multiple interconnected services for a web applications like:

  • rails server / unicorn / puma
  • redis / sidekiq / resque

So that, if one is stopped or started, others get stopped/started too.


Solution

  • Usually a monitoring tool is used for this purpose. One such good tool is God.

    The basic idea is to run God as a system service, and configure your sidekiq to be watched by God. When your server restarts, God runs as a service and it will start your sidekiq workers.

    You have more benefits by using God, to name just a few:

    • notifications: you can configure it to send you notifications when your sidekiq worker dies and gets restarted.
    • resource monitoring: you can configure it to take actions based on predefined rules. For example, restart the job when it consumes too much memory.

    Update: just read an article this morning which might be very helpful: Create, run and manage your Ruby background processes with upstart.