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?
The crucial thing which solved the "process is not running" issue for me was to properly define dir
attribute:
w.dir = "#{Rails.root}"
That fixed the problem.
I faced similar issues. Specifying queue and concurrency settings under sidekiq.yml solved it for me. In your god start,
sidekiq -e #{env} -C #{root}/config/sidekiq.yml
The Sidekiq Github has an example of the yml config. It goes something like:
---
:concurrency: 25
:queues:
- [a, 5]
- [b, 3]
- [c, 2]
- [default, 3]
I hope you have already found a solution though.
I've just used your code to deploy my own god / sidekiq setup, and this change got it working for me. I replaced your w.start
with:
w.start = "bundle exec sidekiq -q release,1 -q artist,2 -q artists,3 -c 20"
(Though of course those queues are just the ones I happened to use, and aren't relevant)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.