From: Thomas Uehlinger Date: 2005-02-08T21:40:12+09:00 Subject: [ANN] Daemons 0.0.1: control your daemon scripts with start/stop commands I'm proud to release the first version of Daemons, a tool to create scripts that run as daemons in the background and that can be controlled by start/stop/restart commands (using pid-files). Get it while it's hot as a gem ('gem install daemons') or from http://rubyforge.org/projects/daemons or read on... -- Thomas Uehlinger From the README: == What is Daemons? Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands. Daemons includes the daemonize.rb script written by Travis Whitton to do the daemonization process. == Basic Usage Layout: suppose you have your self-written server myserver.rb: # this is myserver.rb # it does nothing really useful at the moment loop do sleep(5) end To use myserver.rb in a production environment, you need to be able to run myserver.rb in the _background_ (this means detach it from the console, fork it in the background, release any directories and file descriptors). Just create myserver_control.rb like this: # this is myserver_control.rb require 'rubygems' # if you use RubyGems require 'daemons' Daemons.run('myserver.rb') And use it like this from the console: $ ruby myserver_control.rb start (myserver.rb is now running in the background) $ ruby myserver_control.rb restart (...) $ ruby myserver_control.rb stop For testing purposes you can even run myserver.rb without forking in the background: $ ruby myserver_control.rb run An additional nice feature of Daemons is that you can pass additional arguments to the script that should be daemonized by seperating them by two _hyphens_: $ ruby myserver_control.rb start -- --file=anyfile --a_switch another_argument For further documentation, refer to the module documentation of Daemons. == Download and Installation *Download*: just go to http://rubyforge.org/projects/daemons/ Installation *with* RubyGems: $ su # gem install daemons Installation *without* RubyGems: $ tar xfz daemons-x.x.x.tar.gz $ cd daemons-x.x.x $ su # ruby setup.rb == Documentation For further documentation, refer to the module documentation of Daemons (click on Daemons). The RDoc documentation is also online at http://daemons.rubyforge.org == Author Written in 2005 by Thomas Uehlinger == License The Daemons script is copywrited free software by Thomas Uehlinger . You can redistribute it under the terms specified in the COPYING file of the Ruby distribution. == Feedback and other resources At http://rubyforge.org/projects/daemons.