class Uc::Unicorn::Init
Attributes
server[RW]
worker[RW]
Public Class Methods
new(server)
click to toggle source
# File lib/uc/unicorn/init.rb, line 14 def initialize(server) @server = server end
Public Instance Methods
acquire_lock()
click to toggle source
# File lib/uc/unicorn/init.rb, line 36 def acquire_lock lock_acquired = lock_fd.flock(File::LOCK_SH | File::LOCK_NB ) rescue => e stderr.error "#{e.class} #{e.message}\n #{e.backtrace.join("\n")}" return false end
end_run(worker)
click to toggle source
# File lib/uc/unicorn/init.rb, line 53 def end_run(worker) @worker = worker if last_worker? event_stream.pub :fin, "server #{event_type}" end end
event_type()
click to toggle source
# File lib/uc/unicorn/init.rb, line 18 def event_type @event_type ||= (restart? ? "restart" : "start") end
lock_fd()
click to toggle source
# File lib/uc/unicorn/init.rb, line 49 def lock_fd @lock_fd ||= File.new(lock_file, "a+") end
lock_file()
click to toggle source
# File lib/uc/unicorn/init.rb, line 22 def lock_file @lock_file ||= "tmp/unicorn.lock" end
run()
click to toggle source
# File lib/uc/unicorn/init.rb, line 26 def run event_stream.debug "event_type #{event_type}" acquired = acquire_lock if not acquired error_msg = "unable to acquire shared lock (unicorn)" event_stream.fatal error_msg raise ::Uc::Error, error_msg end end
run_once()
click to toggle source
# File lib/uc/unicorn/init.rb, line 43 def run_once return if @ran_once @ran_once = true run end