ruby-on-railsrubygod

How to configure Ruby God to monitor > 1 process?


I am using the God gem to monitor my processes, and I already have setup a watch for 1 process in a file like this (named config.god)

rails_env = ENV['RAILS_ENV'] || "development"
rails_root = ENV['RAILS_ROOT'] || "/data/buzzsumo2/current"

God.watch do |w|

     w.dir      = "#{rails_root}"
     w.name     = "sidekiq"
     w.interval = 30.seconds
     w.env      = {"RAILS_ENV" => rails_env}
     w.interval = 30.seconds
     w.start = "bundle exec sidekiq -C #{rails_root}/config/sidekiq.yml"
     w.keepalive

     #more logic for transitioning states

end

I start this process by running bundle exec god -c config.god, and can restart it by running bundle exec god restart sidekiq.

Now, if I want to have another watch for another process named "sidekiq2", how do I add it to the same god file? Basically, I want the ability to start and restart 2 processes using God. Note that these 2 processes could run at the same time.


Solution

  • To an existing running God configuration, You can add another process by doing god load sidekiq2.god and then god restart sidekiq2 Create sidekiq2.god with details of sidekiq2 process.