I'm using redis server
and sidekiq
for my cron jobs but some time sidekiq
kills automatically at backend.
I want to restart sidekiq
from my controller's action or automatically when it kills down without stoping my rails application server.
Please suggest me how can I manage this problem?
You can check sidekiq and redis server running or not running by :
def redis_connected?
!!Sidekiq.redis(&:info) rescue false
end
def sidekiq_connected?
ps = Sidekiq::ProcessSet.new
ps.size > 0 ? true : false
end
and you can also start from your controller but this is not a good way because it will start sidekiq but kill rails server.
def start_sidekiq
system "redis-server &" if !redis_connected?
system "bundle exec sidekiq -d" if !sidekiq_connected?
flash[:sidekiq_notification]="Starting server... Please refresh after few seconds"
redirect_to :back
end
or install and use a server monitoring tool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With