1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Indicate in procline that manager have stopped

This commit is contained in:
Dmitry Krasnoukhov 2014-04-14 01:30:25 +03:00
parent 7f5ba22f2e
commit 473de4da8f
2 changed files with 31 additions and 2 deletions

View file

@ -133,13 +133,14 @@ module Sidekiq
end end
def heartbeat(key, data) def heartbeat(key, data)
return if stopped?
proctitle = ['sidekiq', Sidekiq::VERSION] proctitle = ['sidekiq', Sidekiq::VERSION]
proctitle << data['tag'] unless data['tag'].empty? proctitle << data['tag'] unless data['tag'].empty?
proctitle << "[#{@busy.size} of #{data['concurrency']} busy]" proctitle << "[#{@busy.size} of #{data['concurrency']} busy]"
proctitle << 'stopping' if stopped? proctitle << 'stopping' if stopped?
$0 = proctitle.join(' ') $0 = proctitle.join(' ')
return if stopped?
(key) (key)
after(5) do after(5) do
heartbeat(key, data) heartbeat(key, data)

View file

@ -1,5 +1,6 @@
require 'helper' require 'helper'
require 'sidekiq/manager' require 'sidekiq/manager'
require 'sidekiq/util'
class TestManager < Sidekiq::Test class TestManager < Sidekiq::Test
@ -77,9 +78,36 @@ class TestManager < Sidekiq::Test
fetcher.verify fetcher.verify
end end
describe 'heartbeat' do
describe 'proctitle' do
it 'sets useful info' do
mgr = Sidekiq::Manager.new(options)
mgr.heartbeat('identity', heartbeat_data)
proctitle = $0
assert_equal $0, "sidekiq #{Sidekiq::VERSION} myapp [0 of 3 busy]"
$0 = proctitle
end
it 'indicates when stopped' do
mgr = Sidekiq::Manager.new(options)
mgr.stop
mgr.heartbeat('identity', heartbeat_data)
proctitle = $0
assert_equal $0, "sidekiq #{Sidekiq::VERSION} myapp [0 of 3 busy] stopping"
$0 = proctitle
end
end
end
def options def options
{ :concurrency => 3, :queues => ['default'] } { :concurrency => 3, :queues => ['default'] }
end end
def heartbeat_data
{ 'concurrency' => 3, 'tag' => 'myapp' }
end
end end
end end