PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 28, 2022

[FIXED] How to wait for more than 10 minutes a successful deployment on AWS Opsworks?

 September 28, 2022     amazon-web-services, aws-opsworks, continuous-deployment, deployment, shell     No comments   

Issue

I am deploying an application on AWS using AWS Opsworks. I have automated the deployment in a script, and I would like to make my task last as long as the deployment has not been finished on Opsworks.

I am using the command deployment-successful to do it, but it exits 255 after 10 minutes if the deployment is not finished yet. And sometimes our Opsworks deployments last longer than than 10 minutes. Is it possible to catch the exit code to relaunch the command in such case?

I have tried this code but it exits directly 255 without relaunching:

#!/bin/bash

wait_deploy_output() {
  echo "Waiting for deploy to finish..."

  wait_deploy=$(aws opsworks \
    --profile $AWS_PROFILE \
    --region $AWS_REGION \
    wait deployment-successful \
    --deployment-ids $1)

  wait_status=$?

  [ "$wait_status" = 255 ] && wait_deploy_output $1

  if [ "$wait_status" = 0 ]; then
    echo "Deployed successfully!"
  fi

  exit $wait_status
}

wait_deploy_output $deployment_id

Solution

Hi Try with the below modified script:-

#!/bin/bash

wait_status=0

wait_deploy_output() {
  echo "Waiting for deploy to finish..."

  wait_deploy=$(aws opsworks \
    --profile $AWS_PROFILE \
    --region $AWS_REGION \
    wait deployment-successful \
    --deployment-ids $1)

  wait_status=$?

}

wait_deploy_output $deployment_id

  while true
  do
    if [ $wait_status -eq 255 ]; then
       echo "Deployment not successful"
       echo "Re-deploying it again"
       wait_deploy_output $deployment_id
    elif [ "$wait_status" = 0 ]; then
       echo "Deployed successfully!"
       break
    fi
  done

  exit $wait_status


Answered By - Abhijit Pritam Dutta
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing