daemons icon indicating copy to clipboard operation
daemons copied to clipboard

Ruby Daemons Library with the Daemons.Run function

Open thuehlinger opened this issue 11 years ago • 3 comments

Hello Thomas,

I've been developing a back-end server system in ruby and I was using your awesome Daemonization library seen at http://daemons.rubyforge.org/. One of the issues I am hitting is that when I execute the Daemons.run(script) method the process launches and is daemonized but the rest of the script stops running. For a full example please see: http://pastebin.com/PAwKX6RN

This seems like it might be a limitation of forking in Ruby but if I am utilizing your library incorrectly or you have any insight on how I could get my desired end result I appreciate any input.

Thanks, Michael Brune

thuehlinger avatar May 18 '14 17:05 thuehlinger

Is this all the text that's available? Was there a RubyForge ticket ID associated with this message?

sodabrew avatar May 30 '14 21:05 sodabrew

The Markdown parsing somehow didn't parse the second part of the text correctly. Now fixed. This is what I responded:

Hi Michael,

what you are seeing is the intended behavior of Daemons.run, i.e. it passes all control to the given script.It is — in fact — not a a limitation of the fork comman. You can achieve your desired behavior by doing another fork on your on within the loop before calling Daemons.run. Alternatively, you could use Daemons.call to call and daemonize a proc, and then use “load” within the proc to execute the script. See the examples directory within the gem to get some more guidance.

Btw: daemons has moved to https://github.com/thuehlinger/daemons since rubyforge is shutting down soon.

Best,

Thomas

thuehlinger avatar Jun 01 '14 12:06 thuehlinger

What do you think of my suggested program flow in https://github.com/thuehlinger/daemons/issues/5#issuecomment-43450411 - I think that would cover his use case for managing workers within his program.

sodabrew avatar Jun 01 '14 23:06 sodabrew