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

Generate a random hex string as the process id since Process.pid is not supported on all platforms (specifically, does not work on Heroku)

This commit is contained in:
Jake Mack 2013-06-20 10:58:53 -07:00
parent 19a08c2c46
commit b0286efc2b
2 changed files with 19 additions and 1 deletions

View file

@ -26,7 +26,7 @@ module Sidekiq
end
def process_id
Process.pid
@@process_id ||= SecureRandom.hex
end
def hostname

18
test/test_util.rb Normal file
View file

@ -0,0 +1,18 @@
require 'helper'
require 'sidekiq/util'
class TestUtil < Minitest::Test
describe 'util' do
it 'generates the same process id when included in two or more classes' do
class One
include Sidekiq::Util
end
class Two
include Sidekiq::Util
end
assert_equal One.new.process_id, One.new.process_id
end
end
end