Skip to content

Commit

Permalink
Add monit start script
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0i committed Sep 26, 2022
1 parent 0642622 commit f91a4ff
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions monit_restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/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)
kill $(cat target/universal/stage/RUNNING_PID)
;;
*)
echo "usage: $USAGE"
;;
esac
exit 0

0 comments on commit f91a4ff

Please sign in to comment.