Skip to content

Commit

Permalink
Restart also if RUNNING_PID is missing
Browse files Browse the repository at this point in the history
Get PID using lsof and awk.
  • Loading branch information
dr0i committed Oct 30, 2023
1 parent 1243053 commit b8fcc70
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions web/restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,29 @@ $ sudo /etc/ini.d/monit stop
"

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

REPO=$1
HOME="/home/sol"
PID_FILE="target/universal/stage/RUNNING_PID"

cd $HOME/git/$REPO/
mvn clean install -DskipTests=true
cd $HOME/git/$REPO/web
kill $(cat target/universal/stage/RUNNING_PID)
sleep 14
kill -9 $(cat target/universal/stage/RUNNING_PID)
rm target/universal/stage/RUNNING_PID

if [ ! -f $PID_FILE ]; then
echo "RUNNING_PID missing. Getting PID and kill ... "
PID=$(lsof -i:7507 |awk -F'[^0-9]*' '$0=$2' | tail -n1)
kill $PID
else
PID=$(cat $PID_FILE)
kill $PID
sleep 14
kill -9 $PID
rm $PID_FILE
fi
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
Expand Down

0 comments on commit b8fcc70

Please sign in to comment.