Skip to content

Instantly share code, notes, and snippets.

@lachlanagnew
Created February 20, 2019 01:23
Show Gist options
  • Save lachlanagnew/f45ea46179df09799003b605bad1b713 to your computer and use it in GitHub Desktop.
Save lachlanagnew/f45ea46179df09799003b605bad1b713 to your computer and use it in GitHub Desktop.
#!/bin/bash
HOME=/home/ubuntu
APP=$HOME/App
PIDF=$APP/app.pid
CMD=$APP/app.sh
LOG=$HOME/deploy.log
/bin/echo "$(date '+%Y-%m-%d %X'): Initializing Deployment for $APPLICATION_NAME - $DEPLOYMENT_ID " >> $LOG
cd $APP
if [ -f $CMD ]
then
$CMD stop
/bin/echo "$(date '+%Y-%m-%d %X'): Stopping $APPLICATION_NAME" >> $LOG
elif [ -f $PIDF ]
then
PID=`cat $PIDF`
kill -9 $PID
/bin/echo "$(date '+%Y-%m-%d %X'): Killing $APPLICATION_NAME [$PID]" >> $LOG
rm $PIDF
else
/bin/echo "$(date '+%Y-%m-%d %X'): $CMD not found. Proceeding with deployment" >> $LOG
fi
/bin/echo "$(date '+%Y-%m-%d %X'): ** Application Stop Hook Completed **" >> $LOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment