Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Allow -P option to pass named PID file to rails server

#5031

This is a 3 line change, adding the ability for Rails::Server to pass an option to Rack::Server.

Rack::Server currently takes a -P option so that a named PID file can be passed.

Rails::Server currently specifies a default for this option:

:pid         => File.expand_path("tmp/pids/server.pid"),

This is problematic: When starting more than one instance of the server, the server.pid is clobbered by the newer server starting up, so the PID file dropped by rails is actually completely useless in a production environment.

Rails 2 exhibited this same problem. The existence of mongrel_cluster mitigated the problem for most in mongrel deploys though a patch was submitted but pushed back to rails 3. Then of course there is unicorn/passenger/etc which is another can of beans.

The default would remain the same with this change. In my opinion, if Rails is going to drop a PID, it needs to be able to do so properly in production - that is, multiple instances need to be able to drop unique PID files. This allows for easily running multiple severs, for example one can then name the PIDs server.5000.pid, server.5001.pid, and so on.

tl;dr Dropping a PID is pointless unless it can be unique, as each instance will write over the PID. This patch allows it to be specified.

Thanks!

Reported by sudara · July 2nd, 2010 @ 01:17 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. sudara
    sudara
    • Tag changed from rails3 server startup, bug to rails3 server startup, bug, patch

    Patch attached!

    July 2nd, 2010 @ 01:25 AM

  2. José Valim
    José Valim
    • Assigned user set to José Valim
    • Milestone cleared.
    • Importance changed from to Low

    July 7th, 2010 @ 10:33 PM

  3. Repository
  4. Jeremy Kemper