AWS代码部署部署失败作为用户根运行失败



我一直在使用代码管道和代码部署来使用git-hub部署我的asp.net应用程序,每次部署失败时,都会在事件日志中显示此错误消息"指定位置的脚本:以用户root身份运行的脚本/stop_service失败,退出代码为5">
我已经在ec2实例上安装了代码部署代理,这是来自appspec文件的示例

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

在此处输入图像描述

CodeDeploy正在尝试运行脚本"scripts/stop_server",但失败了,例如,因为脚本不在此位置。

如果脚本在这个位置,请通过检查以下位置的日志来检查执行有什么问题:

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

将"[部署组ID]"one_answers"[部署ID]"替换为部署的实际ID。