module Daemons

def call(options = {}, &block)


end
}
serve(conn)
conn = accept_conn()
loop {
# Server loop:
Daemons.call(options) begin

}
:ontop => true
:monitor => true,
:backtrace => true,
options = {
=== Example:

-----
pid-file directory if the application exits due to an uncaught exception
:backtrace:: Write a backtrace of the last exceptions to the file '[app_name].log' in the
:ontop:: When given, stay on top, i.e. do not daemonize the application
same time
:multiple:: Specifies whether multiple instances of the same script are allowed to run at the
=== Options:

+block+:: The block to call in the daemon.

+options+:: A hash that may contain one or more of the options listed below

after spawning the daemon with the new Application object as a return value.
Execute the block in a new daemon. Daemons.call will return immediately
def call(options = {}, &block)
  unless block_given?
    raise "Daemons.call: no block given"
  end
  
  options[:proc] = block
  options[:mode] = :proc
  
  @group ||= ApplicationGroup.new('proc', options)
  
  new_app = @group.new_application(options)
  new_app.start
  return new_app
end

def controller; @controller; end

Return the internal Controller instance.
def controller; @controller; end

def daemonize(options = {})


}
serve(conn)
conn = accept_conn()
loop {
# Server loop:

Daemons.daemonize(options)

}
:ontop => true
:backtrace => true,
options = {
=== Example:

-----
pid-file directory if the application exits due to an uncaught exception
:backtrace:: Write a backtrace of the last exceptions to the file '[app_name].log' in the
:ontop:: When given, stay on top, i.e. do not daemonize the application
=== Options:

+options+:: A hash that may contain one or more of the options listed below

Daemonize the currently runnig process, i.e. the calling process will become a daemon.
def daemonize(options = {})
  @group ||= ApplicationGroup.new(options[:app_name] || 'self', options)
  
  @group.new_application(:mode => :none).start
end

def group; @group; end

Return the internal ApplicationGroup instance.
def group; @group; end

def run(script, options = {})


Daemons.run(File.join(File.dirname(__FILE__), 'myscript.rb'), options)

}
:monitor => true
:backtrace => true,
:mode => :exec,
:ontop => true,
:multiple => true,
:dir => 'pids',
:dir_mode => :script,
:ARGV => ['start', '-f', '--', 'param_for_myscript']
:app_name => "my_app",
options = {
=== Example:

-----

:stop_proc:: A proc that will be called when the daemonized process receives a request to stop (works only for :load and :proc mode)
not call at_exit handlers).
:hard_exit:: When given use exit! to end a daemons instead of exit (this will for example
:keep_pid_files:: When given do not delete lingering pid-files (files for which the process is no longer running).
:log_output:: When given (i.e. set to true), redirect both STDOUT and STDERR to a logfile named '[app_name].output' in the pid-file directory
:monitor:: Monitor the programs and restart crashed instances
pid-file directory if the application exits due to an uncaught exception
:backtrace:: Write a backtrace of the last exceptions to the file '[app_name].log' in the
:exec Execute the script file with Kernel.exec
note that :stop_proc only works for the :load (and :proc) mode.
:mode:: :load Load the script with Kernel.load;
(but the pid-file and other things are written as usual)
:ontop:: When given (i.e. set to true), stay on top, i.e. do not daemonize the application
same time
:multiple:: Specifies whether multiple instances of the same script are allowed to run at the
:dir:: Used in combination with :dir_mode (description above)

(/var/run is used as the pid file directory)
:dir is interpreted as a (absolute or relative) path) or :system
to the script location given by +script+) or :normal (the directory given by
given by :dir is interpreted relative
:dir_mode:: Either :script (the directory for writing the pid files to
If not given, ARGV (the parameters given to the Ruby process) will be used.
['start', 'f', '--', 'param1_for_script', 'param2_for_script'].
These are assumed to be separated by an array element '--', .e.g.
This includes both parameters for Daemons itself and the controlled scripted.
:ARGV:: An array of strings containing parameters and switches for Daemons.
the script.
and log files. Defaults to the basename of
used to contruct the name of the pid files
:app_name:: The name of the application. This will be
=== Options:

+options+:: A hash that may contain one or more of the options listed below

the controlling script from the appropriate directory.
script resides, so this has to be either an absolute path or you have to run
Also note that Daemons cannot detect the directory in which the controlling
Please note that Daemons runs this script with load