Reputation: 1
We have a NodeJS Cloud Foundry application with a DevOps Delivery Pipeline enabled. We are attempting to update our deploy script to allow us to deploy app updates without any downtime. We now have a script that mostly works (see below).
However, we realize that during the deployment, our app will start twice. What do we need to change in the script so only one server initialization will occur? Here is the script:
#!/bin/bash
# Push app
if ! cf app $CF_APP; then
cf set-env "${CF_APP}" NODE_ENV development
cf set-env "${CF_APP}" HOST_NAME bluemix
cf push $CF_APP
else
OLD_CF_APP=${CF_APP}-OLD-$(date +"%s")
rollback() {
set +e
if cf app $OLD_CF_APP; then
cf logs $CF_APP --recent
cf delete $CF_APP -f
cf rename $OLD_CF_APP $CF_APP
fi
exit 1
}
set -e
trap rollback ERR
cf rename $CF_APP $OLD_CF_APP
cf push $CF_APP
cf set-env "${CF_APP}" NODE_ENV development
cf set-env "${CF_APP}" HOST_NAME bluemix
cf restage ${CF_APP}
cf delete $OLD_CF_APP -f
fi
Upvotes: 0
Views: 85
Reputation: 17118
I would suggest to take a broader look and consider what is called "blue green deployment". Basically, you start another app instance and then switch over from the old to the new code version.
There are different approaches you can take to such a High Availability deployment with Cloud Foundry apps on IBM Cloud. There are Cloud Foundry CLI plugins such as "autopilot" or "blue-green-deploy" that can be used. Their goal is to have zero downtime deployments. You can also take them as input to come up with your own scripting.
Upvotes: 0