forked from od-eon/django-cherrypy-odeon
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cherrypy_server.sh
executable file
·69 lines (60 loc) · 997 Bytes
/
cherrypy_server.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
#!/bin/sh
PROCESSES=10
THREADS=1 # threads per process
BASE_PORT=3035 # the first port used
# you need to make the PIDFILE dir and insure it has the right permissions
PIDFILE="/var/run/django/odeon_django_cp.pid"
WORKDIR=`dirname "$0"`
cd "$WORKDIR"
cp_start_proc()
{
N=$1
P=$(( $BASE_PORT + $N - 1 ))
./manage.py runcpserver daemonize=1 port=$P pidfile="$PIDFILE-$N" threads=$THREADS request_queue_size=0
}
cp_start()
{
for N in `seq 1 $PROCESSES`; do
cp_start_proc $N
done
}
cp_stop_proc()
{
N=$1
#[ -f "$PIDFILE-$N" ] && kill `cat "$PIDFILE-$N"`
[ -f "$PIDFILE-$N" ] && ./manage.py runcpserver pidfile="$PIDFILE-$N" stop
rm -f "$PIDFILE-$N"
}
cp_stop()
{
for N in `seq 1 $PROCESSES`; do
cp_stop_proc $N
done
}
cp_restart_proc()
{
N=$1
cp_stop_proc $N
#sleep 1
cp_start_proc $N
}
cp_restart()
{
for N in `seq 1 $PROCESSES`; do
cp_restart_proc $N
done
}
case "$1" in
"start")
cp_start
;;
"stop")
cp_stop
;;
"restart")
cp_restart
;;
*)
"$@"
;;
esac