Created
February 20, 2019 01:25
-
-
Save lachlanagnew/27209f35a7d3d1d0b35161931f5bdfc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
HOME=/home/ubuntu | |
APP=$HOME/App | |
CMD=$APP/app.sh | |
PIDF=$APP/app.pid | |
LOG=$HOME/deploy.log | |
APPLOG=$APP/app.log | |
/bin/echo "$(date '+%Y-%m-%d %X'): ** Validate Service Hook Started **" >> $LOG | |
# Check that the application directory exists | |
if [ -d $APP ] | |
then | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Checking $APPLICATION_NAME Directory => SUCCESS" >> $LOG | |
else | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Checking $APPLICATION_NAME Directory => FAILED" >> $LOG | |
fi | |
# Check that launcher exists | |
if [ -f $CMD ] | |
then | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Checking $APPLICATION_NAME start script => SUCCESS" >> $LOG | |
else | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Checking $APPLICATION_NAME start script => FAILED" >> $LOG | |
fi | |
if [ `$CMD is_running` -eq 1 ] | |
then | |
WC=0 | |
if [ -f $PIDF ] | |
then | |
PID=`cat $PIDF` | |
WC=`ps aux | grep $PID | grep -v grep | wc -c` | |
fi | |
if [ $WC -gt 0 ] | |
then | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Checking $APPLICATION_NAME started => SUCCESS [$PID]" >> $LOG | |
else | |
rm $PIDF | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Checking $APPLICATION_NAME started => FAILURE" >> $LOG | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Could not start $APPLICATION_NAME" >> $APPLOG | |
fi | |
else | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Checking $APPLICATION_NAME started => FAILED" >> $LOG | |
/bin/echo "$(date '+%Y-%m-%d %X'): - Could not start $APPLICATION_NAME" >> $APPLOG | |
fi | |
/bin/echo "$(date '+%Y-%m-%d %X'): ***************************************************************************************" >> $APPLOG | |
/bin/echo "$(date '+%Y-%m-%d %X'): ** AWS CodeDeploy - Deployment complete - $APPLICATION_NAME - $DEPLOYMENT_ID **" >> $APPLOG | |
/bin/echo "$(date '+%Y-%m-%d %X'): ***************************************************************************************" >> $APPLOG | |
/bin/echo "$(date '+%Y-%m-%d %X'): ** Deployment complete - $APPLICATION_NAME - $DEPLOYMENT_ID **" >> $LOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment