0
votes

i have been use code pipeline and code deploy to deploy my asp.net application using git hub , every time deployment failed with this error message in event log " Script at specified location: scripts/stop_service run as user root failed with exit code 5 "
i have been installed the Code Deploy Agent on ec2 instance and here is sample from appspec file

version: 0.0
os: linux
files:
  - source:  /
    destination: /var/www/html/

hooks:
  BeforeInstall:
    - location: scripts/install_dependencies
      timeout: 300
      runas: root
    - location: scripts/start_server
      timeout: 300
      runas: root
  ApplicationStop:
    - location: scripts/stop_server
      timeout: 300
      runas: root

enter image description here

1

1 Answers

0
votes

CodeDeploy is trying to run the script 'scripts/stop_server' and failing e.g. because the script is not present at this location.

If the script is at this location, check whats wrong with the execution by inspecting the log at:

/opt/codedeploy-agent/deployment-root/[deployment-group-ID]/[deployment-ID]/logs/scripts.log

Replace '[deployment-group-ID]' and '[deployment-ID]' with actual Ids of your deployment.