forked from Libki/libki-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-script-template
executable file
·99 lines (78 loc) · 2.08 KB
/
init-script-template
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
### BEGIN INIT INFO
# Provides: libki
# Required-Start: mysql
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start Libki at boot time
# Description: Enable Libki
### END INIT INFO
# Source function library.
. /lib/lsb/init-functions
#HANDLER="gazelle" # gazelle or starman
HANDLER="starman"
PORT="3000"
WORKERS="2"
REQUESTS="50000"
HOME_DIR="/home/libki"
MYAPP="libki"
MYAPP_PATH="$HOME_DIR/libki-server"
PIDFILE="$HOME_DIR/libki.pid"
STATUSFILE="$HOME_DIR/libki.status"
ERRORLOG="/var/log/libki/libki_server.log"
START_SERVER="/usr/local/bin/start_server"
STARMAN="/usr/local/bin/starman"
PLACKUP="/usr/local/bin/plackup"
DAEMON="/usr/local/bin/start_server"
PSGI_FILE="$MYAPP_PATH/$MYAPP.psgi"
DAEMON_OPTS="--daemonize --port $PORT --pid-file $PIDFILE --status-file $STATUSFILE --log-file $ERRORLOG -- "
STARMAN_OPTS="$PLACKUP -I $MYAPP_PATH/lib -s Starman --workers $WORKERS --max-requests $REQUESTS -E production -a $PSGI_FILE"
GAZELLE_OPTS="$PLACKUP -I $MYAPP_PATH/lib -s Gazelle --workers $WORKERS --max-reqs-per-child $REQUESTS -E production -a $PSGI_FILE"
if [ $HANDLER == 'starman' ]
then
HANDLER_OPTS=$STARMAN_OPTS
elif [ $HANDLER == 'gazelle' ]
then
HANDLER_OPTS=$GAZELLE_OPTS
else
echo -n "Unkown handler!"
exit
fi
START_LIBKI="$DAEMON $DAEMON_OPTS $HANDLER_OPTS"
start() {
echo -n "Starting Libki... "
eval $START_LIBKI
RETVAL=$?
echo -n "$START_LIBKI"
echo [ $RETVAL = 0 ]
return $RETVAL
}
restart() {
echo -n "Restarting Libki... "
eval $DAEMON --restart $DAEMON_OPTS
}
stop() {
echo -n "Stopping Libki... "
eval $DAEMON --stop $DAEMON_OPTS
}
kill() {
echo -n "Stopping Libki... "
killproc -p $PIDFILE $START_SERVER
}
# See how we were called.
case "$1" in
start)
start
;;
restart)
restart
;;
stop)
stop
;;
*)
echo $"Usage: libki {start|restart|stop|kill}"
exit 1
esac
exit $RETVAL