[Mongrel] Daemonizing a camping server

Dimitri Aivaliotis aglarond at gmail.com
Tue Mar 20 09:53:39 EDT 2007

Alright, solved my problem.  Don't know if it'll help Matt, as well.
The key is in the documentation comment for daemonize:

    # You must call this *before* frameworks that open files
    # as otherwise the files will be closed by this function.

Looking at the examples/builder.rb script, I see that daemonize is
indeed called before listener (perhaps this should be made more
explicit in the docs).  So, below is a working test script.  The one
other thing I added, was to specify the port to listen on. :)

Oh, no pid file is created, no matter if I give :pid_file to the
Configurator.new call or to the daemonize call as in builder.rb.

- Dimitri

--- begin script "test.rb" ---
#!/usr/bin/env ruby

require 'mongrel'

$mongrel_debug_client = true

Mongrel::Configurator.new( :port => 9000 ) do
  daemonize( :cwd => "/tmp", :log_file => "/tmp/test.log" )
  listener do
    uri "/", :handler => Mongrel::DirHandler.new(".")
--- end script "test.rb" ---

More information about the Mongrel-users mailing list