From: ara.t.howard@... Date: 2006-07-14T00:30:55+09:00 Subject: Re: Nuby Q: Daemonize (other materials have been read!) On Fri, 14 Jul 2006, Rogue Amateur wrote: > unknown wrote: >> On Wed, 12 Jul 2006, Rogue Amateur wrote: >> >>>> >>> > > [snip] > >> fortytwo :~ > daemon sleep 42 >> > > So, this works. So does another, innocuous script I wrote. I even > checked out the daemonize library the other person suggested, and it > works too. My pain in the butt actually need it to work as a daemon, > however, does not work. > > What could cause code which works in interactive mode to fail in daemon > mode? > > I'm checking the code now, and I do have "if debug" statements which > output to STDOUT. Could that be the problem? only unless you need them to go somewhere - the code i sent has them going to /dev/null. > I'm adding some blurbs to try to get the stupid thing to tell me, but it > seems to die so silently (eg: nothing in syslog, which is where most > messages are expected to go), that I can't get enough information. > > I know it manages to send the "shut down the listener" message, which is > a "rescue" action. well - then it must be throwing an error right? post you code and i'm sure someone will spot the error. > Hints, suggestions and other comments? wrap your script with this begin # # your entire script # rescue Exception => e require 'tmpdir' tmp = Dir.tmpdir this = File.basename $0 pid = Process.pid deathlog = File.join tmp, "#{ this }.#{ pid }" m, c, b = e.message, e.class, e.backtrace.join("\n") msg = "%s (%s)\n%s" % [m, c, b] open(deathlog, "w"){|f| f.puts msg} end after it runs do an ls -ltar /tmp there should should find a record of the failure. regards. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama