mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge branch 'master' of github.com:mperham/sidekiq
This commit is contained in:
commit
4e9fd939ba
4 changed files with 22 additions and 7 deletions
|
@ -10,23 +10,23 @@ Capistrano::Configuration.instance.load do
|
||||||
namespace :sidekiq do
|
namespace :sidekiq do
|
||||||
|
|
||||||
desc "Quiet sidekiq (stop accepting new work)"
|
desc "Quiet sidekiq (stop accepting new work)"
|
||||||
task :quiet, :roles => lambda { fetch(:sidekiq_role) } do
|
task :quiet, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||||
run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi"
|
run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl quiet #{current_path}/tmp/pids/sidekiq.pid ; fi"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Stop sidekiq"
|
desc "Stop sidekiq"
|
||||||
task :stop, :roles => lambda { fetch(:sidekiq_role) } do
|
task :stop, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||||
run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout} ; fi"
|
run "cd #{current_path} && if [ -f #{current_path}/tmp/pids/sidekiq.pid ]; then #{fetch(:bundle_cmd, "bundle")} exec sidekiqctl stop #{current_path}/tmp/pids/sidekiq.pid #{fetch :sidekiq_timeout} ; fi"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Start sidekiq"
|
desc "Start sidekiq"
|
||||||
task :start, :roles => lambda { fetch(:sidekiq_role) } do
|
task :start, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||||
rails_env = fetch(:rails_env, "production")
|
rails_env = fetch(:rails_env, "production")
|
||||||
run "cd #{current_path} ; nohup #{fetch(:bundle_cmd, "bundle")} exec sidekiq -e #{rails_env} -C #{current_path}/config/sidekiq.yml -P #{current_path}/tmp/pids/sidekiq.pid >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
|
run "cd #{current_path} ; nohup #{fetch(:bundle_cmd, "bundle")} exec sidekiq -e #{rails_env} -C #{current_path}/config/sidekiq.yml -P #{current_path}/tmp/pids/sidekiq.pid >> #{current_path}/log/sidekiq.log 2>&1 &", :pty => false
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Restart sidekiq"
|
desc "Restart sidekiq"
|
||||||
task :restart, :roles => lambda { fetch(:sidekiq_role) } do
|
task :restart, :roles => lambda { fetch(:sidekiq_role) }, :on_no_matching_servers => :continue do
|
||||||
stop
|
stop
|
||||||
start
|
start
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
trap 'INT' do
|
trap 'INT' do
|
||||||
# Handle Ctrl-C in JRuby like MRI
|
# Handle Ctrl-C in JRuby like MRI
|
||||||
# http://jira.codehaus.org/browse/JRUBY-4637
|
# http://jira.codehaus.org/browse/JRUBY-4637
|
||||||
Thread.main.raise Interrupt
|
Sidekiq::CLI.instance.interrupt
|
||||||
end
|
end
|
||||||
|
|
||||||
trap 'TERM' do
|
trap 'TERM' do
|
||||||
# Heroku sends TERM and then waits 10 seconds for process to exit.
|
# Heroku sends TERM and then waits 10 seconds for process to exit.
|
||||||
Thread.main.raise Interrupt
|
Sidekiq::CLI.instance.interrupt
|
||||||
end
|
end
|
||||||
|
|
||||||
trap 'USR1' do
|
trap 'USR1' do
|
||||||
|
@ -43,6 +43,8 @@ module Sidekiq
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@code = nil
|
@code = nil
|
||||||
|
@interrupt_mutex = Mutex.new
|
||||||
|
@interrupted = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse(args=ARGV)
|
def parse(args=ARGV)
|
||||||
|
@ -80,6 +82,15 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def interrupt
|
||||||
|
@interrupt_mutex.synchronize do
|
||||||
|
unless @interrupted
|
||||||
|
@interrupted = true
|
||||||
|
Thread.main.raise Interrupt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def die(code)
|
def die(code)
|
||||||
|
|
|
@ -76,6 +76,10 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def backlog
|
||||||
|
queues.map {|name, size| size }.inject(0) {|memo, val| memo + val }
|
||||||
|
end
|
||||||
|
|
||||||
def retries_with_score(score)
|
def retries_with_score(score)
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq.redis do |conn|
|
||||||
results = conn.zrangebyscore('retry', score, score)
|
results = conn.zrangebyscore('retry', score, score)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
p Failed: #{failed}
|
p Failed: #{failed}
|
||||||
p Busy Workers: #{workers.size}
|
p Busy Workers: #{workers.size}
|
||||||
p Retries Pending: #{retry_count}
|
p Retries Pending: #{retry_count}
|
||||||
p Queue Backlog: #{queues.map{|q,size| size}.sum}
|
p Queue Backlog: #{backlog}
|
||||||
|
|
||||||
.tabbable
|
.tabbable
|
||||||
ul.nav.nav-tabs
|
ul.nav.nav-tabs
|
||||||
|
|
Loading…
Reference in a new issue