Module: Nanite::DaemonizeHelper

Included in:
Agent, Mapper
Defined in:
lib/nanite/daemonize.rb

Instance Method Summary collapse

Instance Method Details

#daemonize(identity, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/nanite/daemonize.rb', line 3

def daemonize(identity, options = {})
  exit if fork
  Process.setsid
  exit if fork
  STDIN.reopen "/dev/null"
  STDOUT.reopen "#{options[:log_path]}/nanite.#{identity}.out", "a"
  STDERR.reopen "#{options[:log_path]}/nanite.#{identity}.err", "a"
  File.umask 0000
end