Method: Main::Daemon#daemonize!

Defined in:
lib/main/daemon.rb

#daemonize!(options = {}, &block) ⇒ Object

daemonize{|pid| puts “the pid of the daemon is #{ pid }”}



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/main/daemon.rb', line 410

def daemonize!(options = {}, &block)
# optional directory and umask
#
  chdir = options[:chdir] || options['chdir'] || @daemon_dir || '.'
  umask = options[:umask] || options['umask'] || 0

# drop to the background avoiding the possibility of zombies..
#
  detach!(&block)

# close all open io handles *except* these ones
#
  keep_ios(STDIN, STDOUT, STDERR, @lock)

# sane directory and umask
#
  Dir::chdir(chdir)
  File::umask(umask)

# global daemon flag
#
  $DAEMON = true
end