Ruby on Rails
WEBrick

WEBrick is an HTTP server library written in Ruby that uses servlets to extend its capabilities. Built into WEBrick are four servlets, handling CGI, ERb, file directories, and a generic Proc servlet. Ruby on Rails uses WEBrick as a quick and easy webserver to start developing your Rails applications. However, for whatever ease of development WEBrick adds to your application, it is generally considered not suitable for any production environment.

You can find the homepage of WEBrick at http://www.webrick.org

Starting WEBrick in Ruby on Rails

script/server -d -p 3000

This command starts the WEBrick server in daemonized mode on port 3000. The last output you will see before the process detaches includes the PID, so you can issue a kill -INT to this process at any time. Alternatively, you can `pgrep script/server` to find the PID, or issue a `pkill -INT script/server`.

Use SIGINT

Note that WEBrick does not terminate in response to the usual SIGTERM signal sent by kill and system shutdown; it just outputs a message and continues running:

[2008-05-10 13:19:21] ERROR SignalException: SIGTERM
        /usr/local/lib/ruby/1.8/webrick/server.rb:91:in `select'

You must use `kill -INT` instead. (This is the signal sent by Ctrl+C.)

Windows Note

Due to differences in the way processes run on Windows, you cannot start WEBrick as a daemon. Run it as above (via ruby) but without the ‘-d’ option. Use CTRL+C to exit WEBrick.

ruby script/server -p 3000

You may find it useful to do this in a separate command window.

OpenQuestion – How do I configure a production server to run rails applications at startup on my MacBook?