forked from GDG-Ukraine/gdg.org.ua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_production.sh
executable file
·58 lines (50 loc) · 1.3 KB
/
init_production.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
#! /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.pid
IF=0.0.0.0
IF=127.0.0.1
PORT=10110
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-prod"
. "$APP_PATH/.exports"
set -e
case "$1" in
start)
test -f $PID && log_daemon_msg "PID exists: `cat $PID`." && exit 1
log_daemon_msg "Starting web server" "blueberrypy"
blueberrypy serve -b $IF:$PORT -P $PID -e production -d && sleep 2 && \
log_daemon_msg "New blueberrypy with PID `cat $PID` has been started."
exit $?
;;
restart|reload|force-reload)
$0 stop
$0 start
exit $?
;;
stop)
PROC_PID=`cat $PID`
kill $PROC_PID && \
log_daemon_msg "Killed blueberrypy with PID $PROC_PID."
exit $?
;;
*)
log_daemon_msg "Usage: $0 start|stop" >&2
exit 3
;;
esac