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.
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.
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.