forked from kopf/porick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathporick.sh
76 lines (59 loc) · 2.07 KB
/
porick.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Start porick a little less painfully
#
# Stephen Shaw <stesh@netsoc.tcd.ie>
# Change these settings as necessary to fit your installation
APPDIR='/srv/subdomains/porick'
APPCONFIG="$APPDIR/production.ini"
PIDFILE="$APPDIR/porick.pid"
PYTHONPATH=':/usr/local/lib/python2.6/dist-packages/FormEncode-1.2.4-py2.6.egg:/usr/local/lib/python2.6/dist-packages/simplejson-2.5.2-py2.6.egg:/usr/local/lib/python2.6/dist-packages/decorator
-3.3.3-py2.6.egg:/usr/local/lib/python2.6/dist-packages/nose-1.1.2-py2.6.egg:/usr/local/lib/python2.6/dist-packages/Mako-0.7.0-py2.6.egg:/usr/local/lib/python2.6/dist-packages/WebError-0.10.3-p
y2.6.egg:/usr/local/lib/python2.6/dist-packages/WebTest-1.3.4-py2.6.egg:/usr/local/lib/python2.6/dist-packages/Tempita-0.5.1-py2.6.egg:/usr/local/lib/python2.6/dist-packages/SQLAlchemy-0.7.7-py
2.6-linux-x86_64.egg:/usr/local/lib/python2.6/dist-packages/Pylons-1.0.1rc1-py2.6.egg:/usr/local/lib/python2.6/dist-packages/WebOb-1.2b3-py2.6.egg:/usr/local/lib/python2.6/dist-packages/MarkupS
afe-0.15-py2.6.egg:'
running () {
[ -f $PIDFILE ]
}
die () {
echo "$1" >/dev/stderr
exit 1
}
pid () {
head -n 1 "$PIDFILE"
}
start_server () {
if running; then
die "Porick is already running (PID: $(pid))"
fi
cd $APPDIR
exec su -m www-data -c "PYTHONPATH='$PYTHONPATH' paster serve $APPCONFIG --pid-file=$PIDFILE &" >/dev/null 2>&1
}
stop_server () {
if ! running; then
die "Porick isn't running"
fi
kill $(pid) && rm -f $PIDFILE
}
restart_server () {
stop_server
sleep 1
start_server
}
server_status () {
if running; then
echo "Running (PID: $(pid))"
else
echo "Not running"
fi
}
reload_config () {
exec "paster setup-app $APPCONFIG"
}
[ "$1" = "start" ] && (shift; start_server; exit)
[ "$1" = "stop" ] && (shift; stop_server; exit)
[ "$1" = "restart" ] && (shift; restart_server; exit)
[ "$1" = "reload" ] && (shift; restart_server; exit)
[ "$1" = "status" ] && (shift; server_status; exit)
[ $# != 1 ] && cat <<EOF
Usage: $0 <start|stop|restart|reload|status>
EOF