-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matthew Letter
committed
Feb 9, 2016
1 parent
d126953
commit 5a0a4cf
Showing
4 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# This is the Slycat haproxy configuration. | ||
# haproxy gets this file from /etc/haproxy/haproxy.cfg | ||
# May, 2015 | ||
# | ||
|
||
global | ||
log /dev/log local0 | ||
log /dev/log local1 notice | ||
daemon | ||
maxconn 256 | ||
user slycat | ||
group slycat | ||
tune.ssl.default-dh-param 2048 | ||
|
||
defaults | ||
log global | ||
mode http | ||
option forwardfor | ||
timeout connect 5000ms | ||
timeout client 50000ms | ||
timeout server 50000ms | ||
timeout tunnel 1d | ||
|
||
frontend http-in | ||
bind *:80 | ||
redirect scheme https if !{ ssl_fc } | ||
redirect location /projects if { path / } | ||
|
||
bind *:443 ssl crt /etc/slycat/combined.cer | ||
use_backend slycat-feed-server if { path_beg /changes-feed } | ||
default_backend slycat-web-server | ||
|
||
backend slycat-web-server | ||
reqadd X-Forwarded-Proto:\ https | ||
server server1 127.0.0.1:8092 | ||
|
||
backend slycat-feed-server | ||
reqadd X-Forwarded-Proto:\ https | ||
server server1 127.0.0.1:8093 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This is a Slycat rsyslogd config file that permits logging from haproxy. | ||
# rsyslogd gets this file from: /etc/rsyslog.d/haproxy.conf | ||
# 5/2015 | ||
|
||
# Create an addtional socket to listen for haproxy | ||
$AddUnixListenSocket /dev/log | ||
|
||
# Send HAProxy messages to a dedicated logfile | ||
if $programname startswith 'haproxy' then /var/log/slycat/proxy-server.log | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# chkconfig: 345 27 73 | ||
# description: Init scriipt to control the Slycat feed server process. | ||
# | ||
|
||
. /etc/rc.d/init.d/functions | ||
|
||
_progName="slycat-feed-server" | ||
_config="/etc/slycat/web-server-config.ini" | ||
_env="/bin/env LD_LIBRARY_PATH=/home/slycat/install/conda/lib PYTHONPATH=/home/slycat/src/slycat/packages" | ||
_prog="/home/slycat/install/conda/bin/python2.7" | ||
_args="/home/slycat/src/slycat/feed-server/slycat-feed-server.py --config $_config" | ||
_outfile="/var/log/slycat/feed-server-stderr.txt" | ||
_user="slycat" | ||
|
||
pidfile="/var/run/$_progName.pid" | ||
lockfile="/var/lock/subsys/$_progName" | ||
|
||
|
||
start() | ||
{ | ||
echo -n $"Starting $_progName:" | ||
|
||
# check program status, only continue if clean & stopped | ||
rh_status_q | ||
retval=$? | ||
[ $retval -eq 1 ] && echo -n " dead but pidfile exists - use cleanup" && warning && echo && exit 1 | ||
[ $retval -eq 0 ] && echo -n " already running" && warning && echo && exit 1 | ||
|
||
# launch the program in the background, redirect all out to file | ||
runuser -s /bin/bash $_user -c "$_env $_prog $_args > $_outfile 2>&1 &" | ||
|
||
# get the pid | ||
sleep 1 | ||
pid=$(pgrep -U $_user -f "$_prog $_args") | ||
[ -z $pid ] && echo -n " pid not detected" && failure && echo && exit 1 | ||
|
||
# write the pid to the pidfile | ||
echo $pid > $pidfile | ||
retval=$? | ||
[ $retval -ne 0 ] && echo -n " pidfile not created" && warning && echo && exit 1 | ||
touch $lockfile | ||
|
||
sleep 1 | ||
rh_status_q -p $pidfile | ||
retval=$? | ||
[ $retval -ne 0 ] && echo -n " final status failed" && failure && echo && exit 1 | ||
success && echo && return $retval | ||
} | ||
|
||
stop() | ||
{ | ||
echo -n $"Stopping $_progName:" | ||
|
||
rh_status_q | ||
retval=$? | ||
[ $retval -eq 3 ] && echo -n " already stopped" && warning && echo && exit 1 | ||
[ $retval -eq 1 ] && echo -n " dead but pidfile exists" && warning && echo && exit 1 | ||
|
||
killproc -p $pidfile | ||
retval=$? | ||
|
||
[ $retval -eq 0 ] && rm -f $lockfile && rm -f $pidfile && success && echo && return $retval | ||
echo -n " killproc returned non-zero" && warning && echo && exit 1 | ||
} | ||
|
||
clean() | ||
{ | ||
rm -f $pidfile | ||
rm -f $lockfile | ||
} | ||
|
||
rh_status() | ||
{ | ||
echo -n "$_progName:" | ||
status -p $pidfile | ||
} | ||
|
||
rh_status_q() | ||
{ | ||
rh_status >/dev/null 2>&1 | ||
} | ||
|
||
|
||
case "$1" in | ||
start) | ||
start | ||
;; | ||
stop) | ||
stop | ||
;; | ||
status) | ||
rh_status | ||
;; | ||
restart) | ||
stop | ||
start | ||
;; | ||
cleanup) | ||
clean | ||
start | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop|status|restart|cleanup}" | ||
exit 2 | ||
esac | ||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/bin/sh | ||
|
||
# | ||
# chkconfig: 345 27 73 | ||
# description: Init scriipt to control the Slycat web server process. | ||
# | ||
|
||
. /etc/rc.d/init.d/functions | ||
|
||
_progName="slycat-web-server" | ||
_config="/etc/slycat/web-server-config.ini" | ||
_env="/bin/env LD_LIBRARY_PATH=/home/slycat/install/conda/lib PYTHONPATH=/home/slycat/src/slycat/packages" | ||
_prog="/home/slycat/install/conda/bin/python2.7" | ||
_args="/home/slycat/src/slycat/web-server/slycat-web-server.py --config $_config" | ||
_outfile="/var/log/slycat/web-server-stderr.txt" | ||
_user="slycat" | ||
|
||
pidfile="/var/run/$_progName.pid" | ||
lockfile="/var/lock/subsys/$_progName" | ||
|
||
|
||
start() | ||
{ | ||
echo -n $"Starting $_progName:" | ||
|
||
# check program status, only continue if clean & stopped | ||
rh_status_q | ||
retval=$? | ||
[ $retval -eq 1 ] && echo -n " dead but pidfile exists - use cleanup" && warning && echo && exit 1 | ||
[ $retval -eq 0 ] && echo -n " already running" && warning && echo && exit 1 | ||
|
||
# launch the program in the background, redirect all out to file | ||
runuser -s /bin/bash $_user -c "$_env $_prog $_args > $_outfile 2>&1 &" | ||
|
||
# get the pid | ||
sleep 1 | ||
pid=$(pgrep -U $_user -f "$_prog $_args") | ||
[ -z $pid ] && echo -n " pid not detected" && failure && echo && exit 1 | ||
|
||
# write the pid to the pidfile | ||
echo $pid > $pidfile | ||
retval=$? | ||
[ $retval -ne 0 ] && echo -n " pidfile not created" && warning && echo && exit 1 | ||
touch $lockfile | ||
|
||
sleep 1 | ||
rh_status_q -p $pidfile | ||
retval=$? | ||
[ $retval -ne 0 ] && echo -n " final status failed" && failure && echo && exit 1 | ||
success && echo && return $retval | ||
} | ||
|
||
stop() | ||
{ | ||
echo -n $"Stopping $_progName:" | ||
|
||
rh_status_q | ||
retval=$? | ||
[ $retval -eq 3 ] && echo -n " already stopped" && warning && echo && exit 1 | ||
[ $retval -eq 1 ] && echo -n " dead but pidfile exists" && warning && echo && exit 1 | ||
|
||
killproc -p $pidfile | ||
retval=$? | ||
|
||
[ $retval -eq 0 ] && rm -f $lockfile && rm -f $pidfile && success && echo && return $retval | ||
echo -n " killproc returned non-zero" && warning && echo && exit 1 | ||
} | ||
|
||
clean() | ||
{ | ||
rm -f $pidfile | ||
rm -f $lockfile | ||
} | ||
|
||
rh_status() | ||
{ | ||
echo -n "$_progName:" | ||
status -p $pidfile | ||
} | ||
|
||
rh_status_q() | ||
{ | ||
rh_status >/dev/null 2>&1 | ||
} | ||
|
||
|
||
case "$1" in | ||
start) | ||
start | ||
;; | ||
stop) | ||
stop | ||
;; | ||
status) | ||
rh_status | ||
;; | ||
restart) | ||
stop | ||
start | ||
;; | ||
cleanup) | ||
clean | ||
start | ||
;; | ||
*) | ||
echo $"Usage: $0 {start|stop|status|restart|cleanup}" | ||
exit 2 | ||
esac | ||
exit $? |