[Mongrel] Daemonizing a camping server

Matt Zukowski mzukowski at urbacon.net
Tue Mar 20 11:24:00 EDT 2007


Putting the daemonize before the listener call fixes the problem for me
as well.

Below is a skeleton camping app script that should reproduce the
original problem. Just run it using the ruby interpreter.

This is on a Linux 2.6.x box (openSuSE 10.2) so it's definitely not just
a BSD issue.

--------------------

require 'rubygems'
require 'camping'
require 'mongrel/camping'

Camping.goes :MyDaemon

module MyDaemon
        module Controllers
                class Foo < R '/'
                        def get
                                render :foo
                        end
                end
        end

        module Views
                def foo
                        xhtml_strict { head { title "Test" }; body {
"Blah" } }
                end
        end
end

if __FILE__ == $0

  config = Mongrel::Configurator.new :host => "0.0.0.0" do
                # putting daemonize here works
                #daemonize :log_file => '/tmp/mydaemon.log', :cwd =>
File.dirname(File.expand_path(__FILE__))
          listener :port => 9999 do
                  uri '/', :handler =>
Mongrel::Camping::CampingHandler.new(MyDaemon)
                  setup_signals
                end

                # putting it here doesn't :(
                daemonize :log_file => '/tmp/mydaemon.log', :cwd =>
File.dirname(File.expand_path(__FILE__))
        end

        config.run.join

end


This e-mail message is privileged, confidential and subject to copyright. Any unauthorized use or disclosure is prohibited. 
Le contenu du pr'esent courriel est privil'egi'e, confidentiel et soumis `a des droits d'auteur. Il est interdit de l'utiliser ou de le divulguer sans autorisation.




More information about the Mongrel-users mailing list