From: Gennady Date: 2003-12-20T08:44:17+09:00 Subject: Re: 'Daemonizing' a script What do you mean by "silently croaks"? Like nothing happens, just a prompt? Did you check your processes? As a result of this code there must be a detached process with parent id 1 that do not have controlling terminal. Try: ps -ef |grep ruby and scan for a corresponding process (it is Unix, isn't it? It may not work on Windows). On Dec 19, 2003, at 15:11, 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 > > > Sincerely, Gennady Bystritsky