-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbnw.init.d.sh
executable file
·48 lines (44 loc) · 1.25 KB
/
bnw.init.d.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
#!/bin/bash
### BEGIN INIT INFO
# Provides: bnw
# Required-Start: $network $local_fs
# Required-Stop: $network $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: BnW microblogging service
# Description: Twistd instance for BnW service
### END INIT INFO
set -e
NAME=bnw
BNW_PATH=$HOME/bnw
BNW_VENV_PATH=$BNW_PATH/.venv
DAEMON=$BNW_VENV_PATH/bin/twistd
PIDFILE=/tmp/bnw.pid
DAEMON_OPTS="--pidfile=$PIDFILE
--logfile=/tmp/bnw.log
--python=$BNW_PATH/instance.tac"
USER=bnw
GROUP=bnw
source $BNW_VENV_PATH/bin/activate
case "$1" in
start)
echo -n "Starting daemon: $NAME"
start-stop-daemon --start --chuid "$USER" --group "$GROUP" --exec "$DAEMON" -- $DAEMON_OPTS
echo "."
;;
stop)
echo -n "Stopping daemon: $NAME"
start-stop-daemon --stop --oknodo --retry 30 --pidfile "$PIDFILE"
echo "."
;;
restart)
echo -n "Restarting daemon: $NAME"
start-stop-daemon --stop --oknodo --retry 30 --pidfile "$PIDFILE"
start-stop-daemon --start --chuid "$USER" --group "$GROUP" --exec "$DAEMON" -- $DAEMON_OPTS
echo "."
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac
exit 0