Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 85 lines (56 sloc) 2.514 kB
06832d0 @purcell Add an introductory README
authored
1 Runit services for heavy-duty Rails hosting
2 ===========================================
3
4 Here's a bunch of scripts for deploying a full production Rails app
5 that runs under runit.
6
7 This scheme is currently used to run several large production
8 Rails apps, including http://www.looktothestars.org/, and it
9 has workd very nicely for a couple of years now. More reliable
10 than system-wide init.d scripts, and fewer permission headaches.
11
12
13 How to use it
14 =============
15
16 Create an unprivileged user for your Rails app, then set up a
17 system-wide Runit service to manage user-specific services for
18 that user -- see the following page for details:
19
20 http://www.sanityinc.com/articles/init-scripts-considered-harmful
21
22 All further steps assume that you are working as the unprivileged user.
23
24 Now, clone this project into the user's home directory:
25
26 cd
27 git clone git://github.com/purcell/rails-runit.git
28
29 Symlink your rails app's root directory to this directory with the
30 name 'app':
31
32 ln -s ~appuser/releases/current ~/rails-runit/app
33
34 Now you can create some services:
35
36 cd ~/rails-runit
37 ./add-mongrel 4001
38 ./add-mongrel 4002
39 ./add-mongrel 4003
40 ./add-haproxy 4000
41 ./add-nginx 4020 4000
42
0a05748 @purcell README corrections
authored
43 This creates (potential) runit services under ~/rails-runit/service.
44 Symlink them to ~/service, and runit will start them for you.
06832d0 @purcell Add an introductory README
authored
45
46 Once started, you can set your system-wide web server to proxy requests
47 for your Rails app to port 4000 (haproxy => mongrel * 3), or to port 4020
48 (nginx => haproxy => mongrel * 3).
49
50 Browse to port 3998 (= haproxy port - 2) to see the haproxy status
51 page.
52
0a05748 @purcell README corrections
authored
53 You can then easily restart your app (e.g. as part of a capistrano
54 deployment) like this:
55
56 sv restart ~/service/mongrel-*
57
58 Further "add-*" and "*-run" scripts are provided for varnish and
59 ferret_server.
60
06832d0 @purcell Add an introductory README
authored
61
62 Status
63 ======
64
65 The haproxy service assumes that the mongrels will be found on
66 the 10 ports higher than itself.
67
68 The use of the 'production' RAILS_ENV is hard-coded, so look out
69 for that if you try it on your own machine.
70
71 The entire scheme is subject to change -- see below.
72
73
74 Future plans
75 ============
76
77 I'd like to rewrite all this in ruby so we can have templates for the
78 config files in ERB, and to make the port mapping a bit more flexible.
79 The 'run' scripts would then look up their config templates under
80 RAILS_ROOT/config first, and fall back to ~/rails-runit/ if necessary.
81
82 It'd be nice to automatically generate monitrc fragments that could
83 be included by a system-wide monit instance for the purposes of
84 monitoring the app.
Something went wrong with that request. Please try again.