From: Carl Youngblood Date: 2003-12-20T08:46:53+09:00 Subject: Re: 'Daemonizing' a script Never mind. I feel sheepish for bothering the list with this. I just needed to turn off error output to /dev/null to see what was going on. Sorry. :-( Carl Youngblood wrote: > I got this code from Webrick::Daemon that is supposed to turn a ruby > script into a daemon. Though I don't fully understand it, I guess that > means that it detaches it from the terminal that called it. The thing > is, when I run the script without the daemonizing code it works fine, > but when I add the following code it silently croaks. Does anybody know > what might be going wrong? > > Thanks, > Carl Youngblood > > #------------------------------ > > # the following lines "daemonize" this script > exit!(0) if fork > Process::setsid > exit!(0) if fork > Dir::chdir("/") > File::umask(0) > [ STDIN, STDOUT, STDERR ].each{|io| > io.reopen("/dev/null", "r+") > } > > # This is a session storage daemon which can be shared by multiple FCGI > # processes. It's just a hash which is enabled for DRb access. > > require 'drb' > require 'include/localsettings' > > session_data = Hash.new > DRb.start_service("druby://127.0.0.1:#{SESSION_PORT.to_s}", session_data) > DRb.thread.join >