I am running a CICD code deploy that is triggered via a Bitbucket pipeline. It all runs as expected, i.e. the code builds, deploys and the server starts perfectly with no errors.
Problem
However, the deployment will continue to run until it times out, and then will report the deployment as a failure. It is as if the AfterInstall
call to the deploy.sh
is ever released.
Question
What am I doing wrong? What must I do to release the deployment to allow it to complete with the server running in the background?
Do I need to change the deploy.sh
, i.e. it needs to end with a '&'.?
Setup
I have a CodeDeploy set up as follows:
appspec.yml
version: 0.0
os: linux
files:
- source: target/pow-wow-0.0.2-SNAPSHOT.jar
destination: /home/jboss/bitbucket/pow-wow
overwrite: true
file_exists_behavior: OVERWRITE
hooks:
AfterInstall:
- location: scripts/deploy.sh
timeout: 300
deploy.sh
echo "about to deploy to pow-wow ($USER) ..."
export JAVA_HOME=/home/jboss/.sdkman/candidates/java/current
echo $JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH
cd /home/jboss/bitbucket/pow-wow
pwd
if lsof -Pi :8080 -sTCP:LISTEN
then
echo "pow-wow is running"
echo "stopping pow-wow on port 8080 ..."
kill -9 $(lsof -t -i tcp:8080)
else
echo "pow-wow is not running"
fi
mv pow-wow-0.0.2-SNAPSHOT.jar target/
cd /home/jboss/bitbucket/pow-wow/logs
if [ -e nohup.out ]
then
echo "Sorting logs ..."
cat nohup.out >> nohup-$(date --iso).out
echo "archive logs to nohup-date.out and remove nohup.out"
rm nohup.out
fi
echo "starting pow-wow ..."
cd /home/jboss/bitbucket/pow-wow
nohup java -jar -Dspring.profiles.active=uat target/pow-wow-0.0.2-SNAPSHOT.jar > logs/nohup.out &
if [ -e logs/nohup.out ]
then
echo "Created /home/jboss/bitbucket/pow-wow/logs/nohup.out"
fi
echo "Run Start pow-wow."