-
Notifications
You must be signed in to change notification settings - Fork 5
/
monit_restart.sh
executable file
·47 lines (39 loc) · 1.03 KB
/
monit_restart.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
#!/bin/sh
USAGE="<GIT REPO NAME> {start|stop} <PORT> [<JAVA OPTS>]"
if [ $# -lt 3 ]; then
echo "$USAGE
THIS SCRIPT SHOULD ONLY BE USED BY -MONIT-!
If you want to restart an instance, use ./restart.sh
First 3 parameters are mandatory.
Don't forget that the process is monitored by 'monit'.
It will restart automatically if you stop the API.
If you want to stop it permanently, do 'sudo /etc/ini.d/monit stop' first.
"
exit 65
fi
REPO=$1
ACTION=$2
PORT=$3
JAVA_OPTS="$4"
HOME="/home/sol"
# it is important to set the proper locale
. $HOME/.locale
JAVA_OPTS=$(echo "$JAVA_OPTS" |sed 's#,#\ #g')
cd $HOME/git/$REPO
case $ACTION in
start)
if [ -f target/universal/stage/RUNNING_PID ]; then
kill $(cat target/universal/stage/RUNNING_PID)
fi
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" $HOME/activator-dist-1.3.5/activator "start $PORT"
;;
stop)
if [ -f target/universal/stage/RUNNING_PID ]; then
kill $(cat target/universal/stage/RUNNING_PID)
fi
;;
*)
echo "usage: $USAGE"
;;
esac
exit 0