public
Description: Run rails applications reliably as runit services
Homepage: http://www.sanityinc.com/
Clone URL: git://github.com/purcell/rails-runit.git
Click here to lend your support to: rails-runit and make a donation at www.pledgie.com !
rails-runit / haproxy-run
100755 41 lines (35 sloc) 1.447 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh -e
 
PORT=$(basename $(pwd)|awk -F- '{print $2}')
USER=$(id -un)
 
cat - > haproxy.conf <<END
global
log 127.0.0.1 local0 warning
 
defaults
balance roundrobin
mode http
retries 3
option abortonclose
option redispatch
maxconn 4096
timeout connect 300000
timeout client 300000
timeout server 300000
 
listen rails_${USER}_$PORT 127.0.0.1:$PORT
timeout connect 300000
server app-$(($PORT + 1)) 127.0.0.1:$(($PORT + 1)) maxconn 1 check
server app-$(($PORT + 2)) 127.0.0.1:$(($PORT + 2)) maxconn 1 check
server app-$(($PORT + 3)) 127.0.0.1:$(($PORT + 3)) maxconn 1 check
server app-$(($PORT + 4)) 127.0.0.1:$(($PORT + 4)) maxconn 1 check
server app-$(($PORT + 5)) 127.0.0.1:$(($PORT + 5)) maxconn 1 check
server app-$(($PORT + 6)) 127.0.0.1:$(($PORT + 6)) maxconn 1 check
server app-$(($PORT + 7)) 127.0.0.1:$(($PORT + 7)) maxconn 1 check
server app-$(($PORT + 8)) 127.0.0.1:$(($PORT + 8)) maxconn 1 check
server app-$(($PORT + 9)) 127.0.0.1:$(($PORT + 9)) maxconn 1 check
server app-$(($PORT + 10)) 127.0.0.1:$(($PORT + 10)) maxconn 1 check
server fail-$(($PORT - 1)) 127.0.0.1:$(($PORT - 1)) backup check
 
listen stats 127.0.0.1:$(($PORT - 2))
mode http
stats uri /
END
PATH=/usr/local/bin:/opt/local/bin:/usr/bin:/usr/sbin:/bin
exec haproxy -db -f haproxy.conf