module Subserver::Util
This module is part of Subserver
core and not intended for extensions.
Constants
- EXPIRY
Public Instance Methods
fire_event(event, options={})
click to toggle source
# File lib/subserver/util.rb, line 45 def fire_event(event, options={}) reverse = options[:reverse] reraise = options[:reraise] arr = Subserver.options[:lifecycle_events][event] arr.reverse! if reverse arr.each do |block| begin block.call rescue => ex handle_exception(ex, { context: "Exception during Subserver lifecycle event.", event: event }) raise ex if reraise end end arr.clear end
hostname()
click to toggle source
# File lib/subserver/util.rb, line 33 def hostname ENV['DYNO'] || Socket.gethostname end
identity()
click to toggle source
# File lib/subserver/util.rb, line 41 def identity @@identity ||= "#{hostname}:#{$$}:#{process_nonce}" end
logger()
click to toggle source
# File lib/subserver/util.rb, line 29 def logger Subserver.logger end
process_nonce()
click to toggle source
# File lib/subserver/util.rb, line 37 def process_nonce @@process_nonce ||= SecureRandom.hex(6) end
safe_thread(name, &block)
click to toggle source
# File lib/subserver/util.rb, line 22 def safe_thread(name, &block) Thread.new do Thread.current['subserver_label'] = name watchdog(name, &block) end end
watchdog(last_words) { || ... }
click to toggle source
# File lib/subserver/util.rb, line 15 def watchdog(last_words) yield rescue Exception => ex handle_exception(ex, { context: last_words }) raise ex end