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
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
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"
|
||||
end
|
||||
|
||||
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")
|
||||
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
|
||||
|
||||
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
|
||||
start
|
||||
end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
trap 'INT' do
|
||||
# Handle Ctrl-C in JRuby like MRI
|
||||
# http://jira.codehaus.org/browse/JRUBY-4637
|
||||
Thread.main.raise Interrupt
|
||||
Sidekiq::CLI.instance.interrupt
|
||||
end
|
||||
|
||||
trap 'TERM' do
|
||||
# Heroku sends TERM and then waits 10 seconds for process to exit.
|
||||
Thread.main.raise Interrupt
|
||||
Sidekiq::CLI.instance.interrupt
|
||||
end
|
||||
|
||||
trap 'USR1' do
|
||||
|
@ -43,6 +43,8 @@ module Sidekiq
|
|||
|
||||
def initialize
|
||||
@code = nil
|
||||
@interrupt_mutex = Mutex.new
|
||||
@interrupted = false
|
||||
end
|
||||
|
||||
def parse(args=ARGV)
|
||||
|
@ -80,6 +82,15 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
|
||||
def interrupt
|
||||
@interrupt_mutex.synchronize do
|
||||
unless @interrupted
|
||||
@interrupted = true
|
||||
Thread.main.raise Interrupt
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def die(code)
|
||||
|
|
|
@ -76,6 +76,10 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
|
||||
def backlog
|
||||
queues.map {|name, size| size }.inject(0) {|memo, val| memo + val }
|
||||
end
|
||||
|
||||
def retries_with_score(score)
|
||||
Sidekiq.redis do |conn|
|
||||
results = conn.zrangebyscore('retry', score, score)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
p Failed: #{failed}
|
||||
p Busy Workers: #{workers.size}
|
||||
p Retries Pending: #{retry_count}
|
||||
p Queue Backlog: #{queues.map{|q,size| size}.sum}
|
||||
p Queue Backlog: #{backlog}
|
||||
|
||||
.tabbable
|
||||
ul.nav.nav-tabs
|
||||
|
|
Loading…
Reference in a new issue