Permalink
Browse files

Merge branch 'master' of github.com:huacnlee/init.d

  • Loading branch information...
2 parents 2df181b + ded942f commit 748d1e71002e13537626756a93446df6cca7421d @huacnlee committed Dec 14, 2012
Showing with 112 additions and 1 deletion.
  1. +61 −0 haproxy
  2. +30 −0 haproxy.cfg
  3. +20 −0 install_haproxy
  4. +1 −1 install_rvm
View
61 haproxy
@@ -0,0 +1,61 @@
+#! /bin/sh
+
+### BEGIN INIT INFO
+# Provides: nginx
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: starts the nginx web server
+# Description: starts nginx using start-stop-daemon
+### END INIT INFO
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/local/sbin/haproxy
+NAME=haproxy
+DESC=proxy
+
+test -x $DAEMON || exit 0
+
+# Include nginx defaults if available
+if [ -f /etc/haproxy ] ; then
+ . /etc/haproxy
+fi
+
+set -e
+
+. /lib/lsb/init-functions
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ if start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
+ --exec $DAEMON -- -f "/usr/local/etc/haproxy.cfg" -p "/var/run/$NAME.pid" || true
+ then
+ echo "$NAME."
+ else
+ echo "failed"
+ fi
+ ;;
+ stop)
+ echo -n "Stopping $DESC: "
+ for pid in $(cat /var/run/$NAME.pid) ; do
+ /bin/kill $pid || return 4
+ done
+ rm -f /var/run/$NAME.pid
+ echo "$NAME."
+ ;;
+ restart)
+ ${0} stop
+ ${0} start
+ ;;
+ status)
+ status_of_proc -p /var/run/$NAME.pid "$DAEMON" haproxy && exit 0 || exit $?
+ ;;
+ *)
+ echo "Usage: $NAME {start|stop|restart|status}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
View
@@ -0,0 +1,30 @@
+# this config needs haproxy-1.1.28 or haproxy-1.2.1
+
+global
+ log 127.0.0.1 local0
+ log 127.0.0.1 local1 notice
+ maxconn 4096
+ uid 99
+ gid 99
+ daemon
+
+defaults
+ log global
+ mode http
+ option httplog
+ option dontlognull
+ retries 3
+ redispatch
+ maxconn 2000
+ contimeout 5000
+ clitimeout 50000
+ srvtimeout 50000
+
+listen :8080
+ cookie SERVERID rewrite
+ stats uri /haproxy_status
+ stats refresh 5s
+ balance roundrobin
+ server app1_1 127.0.0.1:3000 cookie app1inst1 check inter 2000 rise 2 fall 5
+ # server app1_2 127.0.0.1:3001 cookie app1inst2 check inter 2000 rise 2 fall 5
+
View
@@ -0,0 +1,20 @@
+echo "-----------------------------------------------------------------------"
+echo "Now will install Haproxy 1.4.22..."
+curl -O http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.22.tar.gz
+tar zxf haproxy-1.4.22.tar.gz
+cd haproxy-1.4.22
+make TARGET=linux26 && sudo make install
+cd ..
+sudo rm -R haproxy-1.4.22
+rm haproxy-1.4.22.tar.gz
+echo "Haproxy install successed."
+echo "-----------------------------------------------------------------------"
+echo "Now install service to /etc/init.d ..."
+
+
+sudo cp haproxy /etc/init.d/haproxy
+sudo chmod +x /etc/init.d/haproxy
+sudo update-rc.d haproxy defaults
+sudo cp haproxy.cfg /usr/local/etc/haproxy.cfg
+
+sudo /etc/init.d/haproxy start
View
@@ -5,7 +5,7 @@ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bash
source ~/.bash_profile
echo ""
echo -n "Replace Ruby Download url to Taobao Mirror..."
-sed -i 's/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g' ~/.rvm/config/db
+sed -i -e 's/ftp\.ruby-lang\.org\/pub\/ruby/ruby\.taobao\.org\/mirrors\/ruby/g' ~/.rvm/config/db
echo "[Done]"
echo ""
echo ""

0 comments on commit 748d1e7

Please sign in to comment.