lib/puma/daemon/runner_adapter.rb in puma-daemon-0.2.2 vs lib/puma/daemon/runner_adapter.rb in puma-daemon-0.2.3

- old
+ new

@@ -3,35 +3,47 @@ require_relative 'version' module Puma module Daemon module RunnerAdapter - attr_reader :options - attr_accessor :has_demonized + class << self + def included(base) + base.class_eval do + attr_reader :options + attr_accessor :has_demonized + end - def output_header(mode) - super(mode) + base.class_eval do + def output_header(mode) + super(mode) - daemonize! if daemon? - end + daemonize! if daemon? + end - def daemon? - options[:daemon] - end + def daemon? + options[:daemon] + end - def daemonize! - return if has_demonized + def daemonize! + return if has_demonized - log '* Puma Daemon: Demonizing...' - log "* Gem: puma-daemon v#{::Puma::Daemon::VERSION}" - log "* Gem: puma v#{::Puma::Const::VERSION}" + log '* Puma Daemon: Demonizing...' + log "* Gem: puma-daemon v#{::Puma::Daemon::VERSION}" + log "* Gem: puma v#{::Puma::Const::VERSION}" - Process.daemon(true, true) - self.has_demonized = true - end + Process.daemon(true, true) + self.has_demonized = true + end - def log(str) - super(str) unless str == 'Use Ctrl-C to stop' + def log(str) + if super.respond_to?(:log) + super(str) unless str == 'Use Ctrl-C to stop' + else + puts(str) + end + end + end + end end end end end