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
Mike Perham ba8c8a57b9 Rework process/worker data model.
We no longer have a global 'workers' set but rather a global 'processes' set.  Each process has its own workers hash, keyed by thread id.

Rely as much as possible on Redis key expiration to naturally prune any lingering data.  Process data only has a one minute TTL, with the heartbeat refreshing the TTL, so it will expire quickly after a process dies.
2014-03-07 22:41:10 -08:00

37 lines
627 B
Ruby

require 'socket'
require 'sidekiq/exception_handler'
require 'sidekiq/core_ext'
module Sidekiq
##
# This module is part of Sidekiq core and not intended for extensions.
#
module Util
include ExceptionHandler
EXPIRY = 60 * 60 * 24
def watchdog(last_words)
yield
rescue Exception => ex
handle_exception(ex, { :context => last_words })
raise ex
end
def logger
Sidekiq.logger
end
def redis(&block)
Sidekiq.redis(&block)
end
def hostname
Socket.gethostname
end
def identity
@@identity ||= "#{hostname}:#{$$}"
end
end
end