class Daemonite
Public Class Methods
new(opts={},&blk)
click to toggle source
# File lib/daemonite.rb, line 200 def initialize(opts={},&blk) @opts = DAEMONISM_DEFAULT_OPTS.merge(opts) daemonism @opts, &blk end
Public Instance Methods
go!()
click to toggle source
# File lib/daemonite.rb, line 209 def go! begin @at_startup.call(@opts) if @at_startup @opts[:block].call(@opts) rescue SystemExit, Interrupt puts "Server stopped due to interrupt (PID:#{Process.pid})" rescue => e puts "Server stopped due to error (PID:#{Process.pid})" end end
loop!()
click to toggle source
# File lib/daemonite.rb, line 220 def loop! begin @at_startup.call(@opts) if @at_startup loop do @opts[:block].call(@opts) end unless @opts[:block].nil? rescue SystemExit, Interrupt puts "Server stopped due to interrupt (PID:#{Process.pid})" rescue => e puts "Server stopped due to error (PID:#{Process.pid})" end end
run(&block)
click to toggle source
# File lib/daemonite.rb, line 205 def run(&block) @opts[:block] = block end