# Run your production apps with style

**URL:** <https://www.ruby-forum.com/t/run-your-production-apps-with-style/114102>\
**Category:** Rails\
**Created:** [September 7, 2007, 10:35pm UTC](https://www.ruby-forum.com/t/run-your-production-apps-with-style/114102 "2007-09-07T22:35:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerdmaster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c68b51/32.png) [@nerdmaster](https://www.ruby-forum.com/u/nerdmaster)\
**Post date:** [September 7, 2007, 10:35pm UTC](https://www.ruby-forum.com/t/run-your-production-apps-with-style/114102/1 "2007-09-07T22:35:31Z")

</div>

What do cool kids everywhere have? Style. In fact, if you don’t have  
style, you’re probably not one of the cool kids, and you are on the  
outside looking in. You know you want to have style, but you’re not  
sure what exactly it is, and how do you get it?

What it is: style is the new way to run your Rails apps in production.  
How do you get it: sudo gem install ruby-style

Inspired by Erlang’s supervision trees, style starts a supervisor  
process to keep track of your listening TCP socket(s) (one per port).  
It then forks a configurable number of listening child processes per  
socket. When you go to upgrade to a new version of your application,  
you just send a signal to the supervisor (or run style restart), and it  
replaces all child processes with new ones running your updated code,  
listening on the same socket, to ensure that you never lose a client  
request (without even touching your webserver).

But wait there’s more: style automatically restarts dead child  
processes, which may be useful if you have to rely on a not quite  
perfect Ruby extension that occassionally crashes your app.

If you install style in the next 10 minutes, you’ll also get the power  
to increase and decrease the number of listeners per socket without any  
configuration, for dealing with varying levels of traffic.

So don’t wait, install style now!

style stands for “Supervised TCPServer, Yielding Listeners Easily”.

Here’s the usage, listing the various commands, options, and defaults:

style [option value, …] (decrement|halt|increment|restart|start|stop)  
Options:  
-b, --bind IP address to bind to [127.0.0.1]  
-c, --config Location of config file [config/style.yaml]  
-d, --directory Working directory [.]  
-f, --fork Number of listners on each port [1]  
-k, --killtime Number of seconds to wait when killing each child  
[2]  
-l, --logfile Where to redirect STDOUT and STDERR  
[log/style.log]  
-n, --number Number of ports to which to bind [1]  
-p, --port Starting port to which to bind [9999]  
-P, --pidfile Location of pid file [log/style.pid]  
-s, --style Type of style to use [RailsMongrel]  
-u, --unsupervised Whether to run unsupervised [No]

Here’s what the various commands and signals do:

- decrement (USR2) - Decrease the number of listeners per port by 1
- halt (TERM) - Immediately shutdown the child processes and exit
- increment (USR1) - Increase the number of listeners per port by 1
- restart (HUP) - Replace the current listeners with new listeners
- start - Starts the supervisor process and the listening processes
- stop (INT) - Gracefully shutdown the child processes and exit

Currently, style supports running Rails with Mongrel (RailsMongrel  
style, the default), as well as running Rails over SCGI (RailsSCGI  
style). I don’t have that much experience with Mongrel, though the apps  
I tested style with do work, so hopefully it works for you. See the  
README in the gem for more information. Use Rubyforge to report any  
problems or bugs ([http://rubyforge.org/projects/ruby-style/](http://rubyforge.org/projects/ruby-style/)). Enjoy and  
let me know what you think.

Jeremy
