Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- DEPLOY_VERSION=$1
- echo $DEPLOY_VERSION
- if [ -z "$DEPLOY_VERSION" ]; then
- echo "Invalid Version supplied, not going to deploy"
- exit 2
- fi
- echo "Deploying new version of the Movie-App $1"
- sudo apt-get update -y
- sudo apt-get install openjdk-8-jre-headless -y
- sudo apt-get install openjdk-8-jdk -y
- if ! which aws > /dev/null; then
- echo -e "Command not found! Now Installing"
- sudo apt-get install awscli -y
- fi
- BUSY_PORT=$(sudo fuser 8080/tcp)
- if [ -z "$BUSY_PORT" ]; then
- sudo fuser -k 8080/tcp
- fi
- sudo mkdir artifacts
- sudo aws s3 cp s3://jenkinsupgrad/backend/$1 artifacts/${DEPLOY_VERSION}/ --region ap-south-1 --recursive
- sudo kill $(ps aux | grep '[j]ava -jar target/movieapp-api-1.0.0-SNAPSHOT.jar' | awk '{print $2}')
- echo "Wait before restarting service"
- sleep 5
- cd artifacts/${DEPLOY_VERSION}/movieapp-api/
- sudo nohup java -jar target/movieapp-api-1.0.0-SNAPSHOT.jar -y >/dev/null 2>&1 &
- echo "Service is restarting, please wait... "
- sleep 45
- BUSY_PORT=$(sudo fuser 8080/tcp)
- echo $BUSY_PORT
- if [ ! -z "$BUSY_PORT" ]; then
- echo "Service restarted"
- exit 0
- else
- echo "Error while restarting service"
- exit 2
- fi
Add Comment
Please, Sign In to add comment