I'm trying to use the 'daemons' gem to daemonize the ruote engine for a single workflow. However I seem to be doing something fundamentally wrong.
My code in it's simplest form:
wfid = ruote.launch(workflow)
puts wfid
Daemons.daemonize
r = ruote.wait_for(wfid, :timeout => 10800)
I get the workflow ID but then the workflow doesn't run. I used noisy output and it just doesn't output anything. I added some debug 'puts' after the Daemons.daemonize and ruote.wait_for calls and the code get's to the first but not the second output, so it hangs somewhere in ruote.wait_for.
I also tried Process.daemon in ruby 2.0 as well as a simple
exit if fork
Process.setsid
exit if fork
... redirect outputs to /dev/null, etc. ...
But they all yield the same result. The process outputs the workflow ID, daemonizes and is running in the process list, but it is not doing anything. By that I mean that the first participant in the workflow is supposed to write some data to a redis server and even before that it puts some text to stdout which should show up in the daemon log file, but it never does.
Interestingly if I call Daemons.daemonize({ontop: true}) which will make it stay on top and not fork or detach from the terminal, than it works and the workflow executes.
I also tried daemonizing the Process before launching the workflow but that didn't work either. Meaning the workflow launches and the wfid is written to the daemon log, but after that the first participant in the workflow isn't doing anything just like before.
Any suggestions what I might be doing wrong or what I could try to better debug the problem?