-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·67 lines (45 loc) · 1.67 KB
/
deploy.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/bash
GIT_DIR=$(git rev-parse --show-toplevel)
source ~/perl5/perlbrew/etc/bashrc
if [ -f $GIT_DIR/envfile.sh ]; then
source $GIT_DIR/envfile.sh
fi
STARMAN_BIN="$(which starman)"
DAEMON="$(which start_server)"
line (){
perl -e "print '-' x 40, $/";
}
mkdir -p $GIT_DIR/log/
up_server (){
PSGI_APP_NAME="$1"
PORT="$2"
WORKERS="$3"
ERROR_LOG="/tmp/libre.error.log"
STATUS="/tmp/libre.start_server.status"
PIDFILE="/tmp/libre.start_server.pid"
touch $ERROR_LOG
touch $PIDFILE
touch $STATUS
STARMAN="$STARMAN_BIN -I$GIT_DIR/lib --preload-app --error-log=$ERROR_LOG --workers $WORKERS $GIT_DIR/$PSGI_APP_NAME"
DAEMON_ARGS=" --pid-file=$PIDFILE --signal-on-hup=QUIT --status-file=$STATUS --port $PORT -- $STARMAN"
echo STDERR "Restarting... $DAEMON --restart $DAEMON_ARGS"
$DAEMON --restart $DAEMON_ARGS
if [ $? -gt 0 ]; then
echo STDERR "Restart failed, application likely not running. Starting..."
echo STDERR "/sbin/start-stop-daemon -b --start --pidfile $PIDFILE --chuid $USER -u $USER --exec $DAEMON --$DAEMON_ARGS"
/sbin/start-stop-daemon -b --start --pidfile $PIDFILE --chuid $USER -u $USER --exec $DAEMON --$DAEMON_ARGS
if [ $? -gt 0 ]; then
echo STDERR "Start failed again... starting in foreground";
/sbin/start-stop-daemon --start --pidfile $PIDFILE --chuid $USER -u $USER --exec $DAEMON --$DAEMON_ARGS
fi
fi
}
cpanm . --installdeps
sqitch deploy -t $SQITCH_DEPLOY
export DBIC_TRACE=0
echo STDERR "Restaring server...";
up_server "libre.psgi" $API_PORT $API_WORKERS
line
# Daemons.
./script/daemon/Emailsd restart
./script/daemon/Emailsd status