This repository has been archived by the owner on Aug 24, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
init.sh
executable file
·66 lines (58 loc) · 1.52 KB
/
init.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
#! /bin/sh -e
### BEGIN INIT INFO
# Provides: blueberrypy
# Required-Start: $remote_fs $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Set the CPU Frequency Scaling governor to "ondemand"
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
APP_PATH=/home/gtug2/gdg.org.ua
PID_PATH=/var/tmp/run
PID=$PID_PATH/gdg.org.ua.development.pid
IF=0.0.0.0
IF=127.0.0.1
PORT=11010
cd $APP_PATH
mkdir -p $PID_PATH
. /lib/init/vars.sh
. /lib/lsb/init-functions
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
. "$APP_PATH/.exports-dev"
. "$APP_PATH/.exports"
set -e
case "$1" in
start)
test -f $PID && log_daemon_msg "PID exists: $PROC_PID." && exit 1
log_daemon_msg "Starting web server" "blueberrypy"
blueberrypy serve -b $IF:$PORT -P $PID -d && sleep 2 && \
log_daemon_msg "New blueberrypy with PID `cat $PID` has been started."
exit $?
;;
restart)
PROC_PID=`cat $PID`
# Send SIGHUP
kill -9 $PROC_PID
exit $?
;;
reload)
PROC_PID=`cat $PID`
# send SIGUSR1 as a number, since sh doesn't understand that
kill -10 $PROC_PID
exit $?
;;
stop)
PROC_PID=`cat $PID`
# Send SIGTERM
kill -15 $PROC_PID && \
log_daemon_msg "Killed blueberrypy with PID $PROC_PID."
exit $?
;;
*)
log_daemon_msg "Usage: $0 start|stop|restart|reload" >&2
exit 3
;;
esac