Method: Daemonize.simulate

Defined in:
lib/daemons/daemonize.rb

.simulate(logfile_name = nil, app_name = nil) ⇒ Object

Simulate the daemonization process (:ontop mode) NOTE: $stdout and $stderr will not be redirected to the logfile, because in :ontop mode, we normally want to see the output



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/daemons/daemonize.rb', line 24

def simulate(logfile_name = nil, app_name = nil)
  $0 = app_name if app_name

  # Release old working directory
  Dir.chdir '/'

  close_io

  # Free $stdin and point it to somewhere sensible
  begin; $stdin.reopen '/dev/null'; rescue ::Exception; end

  # Split rand streams between spawning and daemonized process
  srand
end