I have been looking for the configuration on how to start sidekiq using the god monitoring system. Below is the god file i use to start sidekiq.
rails_env = ENV['RAILS_ENV'] || "production"
rails_root = ENV['RAILS_ROOT'] || "/home/ubuntu/Projects/app"
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 = "/home/ubuntu/.rvm/gems/ruby-1.9.3-p0/bin/ruby -f #{rails_root}/ sidekiq -c 25 -q worker,15 -q distributor,5"
w.uid = 'ubuntu'
# determine the state on startup
w.transition(:init, { true => :up, false => :start }) do |on|
on.condition(:process_running) do |c|
c.running = true
end
end
# determine when process has finished starting
w.transition([:start, :restart], :up) do |on|
on.condition(:process_running) do |c|
c.running = true
c.interval = 5.seconds
end
# failsafe
on.condition(:tries) do |c|
c.times = 5
c.transition = :start
c.interval = 5.seconds
end
end
# start if process is not running
w.transition(:up, :start) do |on|
on.condition(:process_running) do |c|
c.running = false
end
end
end
When I run this script using the god
command the god server is "showing process not running" as if nothing is happening. I believe I am not calling the sidekiq using the w.start
correctly,
I use bundle exec sidekiq -c 25 -q worker,15 -q distributor,5
under development mode and it was working fine.
What I am I missing? Is there a different way how to deploy the sidekiq workers?