I have a Node.js application which is being automatically deployed to Amazon Web Service through Codeship using the CodeDeploy AWS deployment system.
During the deployment process I've set in my appspec.yml for the currently running web application to be stopped. Once the deployment is complete, I want the web application to be started up again.
os: linux
files:
- source: /
destination: /var/www/app2
hooks:
AfterInstall:
- location: bash_scripts/stop_forever.sh
runas: ec2-user
ApplicationStart:
- location: bash_scripts/start_forever.sh
runas: ec2-user
However I've not yet been able to have either of these scripts to be called successfully from the appspec.yml file during a deployment.
The current error I'm seeing in the AWS deployment agent log is
Error CodeScriptMissing
Script Name /var/scripts/stop_forever.sh
MessageScript does not exist at specified location: /var/scripts/stop_forever.sh
Log TailLifecycleEvent - ApplicationStop
This seems to refer to an older version of the appspec.yml file which was attempting to run these scripts in a different location. Even though I've changed the contents of the appspec.yml file in the deployed package, this error message remains the same on each deploy.
In addition to appspec.yml file listed above, I've also tried making the following changes:
Unfortunately there is very little online in terms of appspec.yml troubleshooting, other than the AWS documentation.
What very obvious thing I am doing wrong?
The ApplicationStop
hook is being called from the previously installed deployment before trying to run the current deployment appspec.yml
file.
In order to prevent this from happening you'll have to remove any previously installed deployment from the server.
sudo service codedeploy-agent stop
/opt/codedeploy-agent/deployment-root
sudo service codedeploy-agent start