On Fri, 6 Jan 2006, Payton Swick wrote: > Has anyone used the Daemons library (http://daemons.rubyforge.org/) > extensively? I'm trying to do something that doesn't appear covered by the > examples, and I'm wondering if I need to reinvent the wheel. > > What I'd like to do is to easily add functionality to my script similar to > the way that fetchmail works, ie: > > When starting the script with one command-line option (eg: --daemon), I > daemonize it and start it running (saving the PID in a file). > > When starting the script with another command-line option (eg: --stop), it > finds the PID file and kills the instance. > > In a sense, I'd like to combine the wrapper method given in the examples and > the script it runs, but the wrapper example seems to absorb command-line > options, and I want to call those functions from within Ruby instead. > > Suggestions? > > -Payton ruby queue and dirwatch both do this. http://codeforpeople.com/lib/ruby/dirwatch/ http://codeforpeople.com/lib/ruby/rq/ atomic creation of files is trickier than one might imagine. is this on *nix? is so checkout my lockfile class and posixlock. it's very important to note that there is ONE atomic creation operator on *nix and it is NOT open or mkdir - symlink is the one. 'man lockfile' might be illuminating. cheers. -a -- =============================================================================== | ara [dot] t [dot] howard [at] noaa [dot] gov | all happiness comes from the desire for others to be happy. all misery | comes from the desire for oneself to be happy. | -- bodhicaryavatara ===============================================================================