I'm deploying my site using AWS codedeploy. My application stop step looks like this:
ApplicationStop:
- location: deploymet/codedeploy/commands/application-stop/remove-self-from-loadbalancer.sh
timeout: 600
runas: root
And this script looks like this:
source ~/.bashrc
cd /var/www/html/laravel
if [ "$LARAVEL_ENV" = "production" ]
then
php artisan deployment:remove-self-from-loadbalancer --env=$LARAVEL_ENV
fi
Running the script manually takes about a second, but when a deploy runs it hangs and fails after 30 seconds, throwing Script at specified location: deploymet/codedeploy/commands/application-stop/remove-self-from-loadbalancer.sh failed to complete in 30 seconds
.
The source used sets the env to production, and I can see the expected effect: a server is being removed from the load balancer almost immediately after the deployment starts.
As far as I understand, this timeout should not occur until after 10 minutes. Why is this happening so quickly?
Best Answer
We were able to solve this. Reading the documentation more carefully, my colleague came up with a suggestion. The CodeDeploy agent stores the latest successful deploy install in
/opt/codedeploy-agent/deployment-root/some-dir/some-other-dir
. During the next deploy, the appspec and scripts stored there are being used for the first steps of the deployment. So we had to log into each server, go to that dir, and change the timeout in the appspec manually.