Skip to content

Commit

Permalink
Add restart.sh; remove RUNNING_PID when starting
Browse files Browse the repository at this point in the history
This makes sure that monit can start the process properly.
  • Loading branch information
dr0i committed Oct 17, 2022
1 parent 9ccd4b2 commit a98cb75
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions monit_restart.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ case $ACTION in
start)
if [ -f target/universal/stage/RUNNING_PID ]; then
kill $(cat target/universal/stage/RUNNING_PID)
rm target/universal/stage/RUNNING_PID
fi
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" $HOME/activator-dist-1.3.5/activator "start $PORT"
;;
Expand Down
36 changes: 36 additions & 0 deletions restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

USAGE="\nusage: <GIT REPO NAME>
This script will just echo -en \033[1mSTOP\033[0m the process!
First parameter is mandatory.
The process is normally be monitored by 'monit'.
Monit will automatically restart it when it's stopped.
Have a look at /etc/monit/conf.d/play-instances.rc to see
which paramters are used (port, java opts etc.)
To see if monit is really observing your instances, try:
$ monit status
If you want to stop it permanently via cmd, do this first:
$ sudo /etc/ini.d/monit stop
"

if [ ! $# -eq 1 ]; then
echo "$USAGE"
exit 65
fi

REPO=$1
ACTION=$2
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
kill $(cat target/universal/stage/RUNNING_PID)
echo "Going to sleep for 11 seconds. Then lookup the process list for the repo name.
If everything is fine, 'monit' is going to start the $REPO instance ..."
sleep 11

ps -ef | grep $REPO
exit 0

0 comments on commit a98cb75

Please sign in to comment.