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

49 lines
857 B
Ruby
Raw Normal View History

2012-09-16 10:28:25 -04:00
require 'socket'
require 'sidekiq/exception_handler'
require 'sidekiq/core_ext'
2012-01-22 14:32:38 -05:00
module Sidekiq
2012-02-17 16:39:36 -05:00
##
# This module is part of Sidekiq core and not intended for extensions.
#
2012-01-22 14:32:38 -05:00
module Util
include ExceptionHandler
2012-01-22 14:32:38 -05:00
2012-09-08 22:50:03 -04:00
EXPIRY = 60 * 60 * 24
2012-01-22 14:32:38 -05:00
def watchdog(last_words)
yield
2012-08-29 23:20:20 -04:00
rescue Exception => ex
handle_exception(ex, { :context => last_words })
raise ex
2012-01-22 14:32:38 -05:00
end
def logger
Sidekiq.logger
2012-01-22 19:01:46 -05:00
end
def redis(&block)
Sidekiq.redis(&block)
end
2012-09-16 10:27:49 -04:00
def hostname
Socket.gethostname
end
def identity
@@identity ||= "#{hostname}:#{$$}"
end
2014-05-14 00:41:40 -04:00
def fire_event(event)
Sidekiq.options[:lifecycle_events][event].each do |block|
begin
block.call
rescue => ex
handle_exception(ex, { :event => event })
end
end
end
2012-01-22 14:32:38 -05:00
end
end