我的配置一直持续到昨天。我添加了nginx NodeJS https redirect extension from AWS。现在,当我尝试通过Elastic Beanstalk配置添加新的环境变量时,我收到此错误:
[Instance: i-0364b59cca36774a0] Command failed on instance. Return code: 137 Output: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf + service nginx stop Stopping nginx: /sbin/service: line 66: 27395 Killed env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS}. Hook /opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
当我查看eb-activity.log时,我看到了这个错误:
[2018-02-18T17:24:58.762Z] INFO [13848] - [Configuration update 1.0.61@112/ConfigDeployStage1/ConfigDeployPostHook/99_kill_default_nginx.sh] : Starting activity...
[2018-02-18T17:24:58.939Z] INFO [13848] - [Configuration update 1.0.61@112/ConfigDeployStage1/ConfigDeployPostHook/99_kill_default_nginx.sh] : Activity execution failed, because: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
+ service nginx stop
Stopping nginx: /sbin/service: line 66: 14258 Killed env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} (ElasticBeanstalk::ExternalInvocationError)
caused by: + rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
+ service nginx stop
Stopping nginx: /sbin/service: line 66: 14258 Killed env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS} (Executor::NonZeroExitStatus)
我做错了什么?最近发生了什么变化,因为几个月前我改变了一个环境变量就行了。
答案 0 :(得分:6)
我也有这个问题,亚马逊承认文档中的错误。这是一个可以在.ebextensions配置文件中使用的重启脚本。
adb devices
答案 1 :(得分:1)
service nginx stop
退出,状态为137(已杀死)。
您的脚本以#!/bin/bash -xe
参数-e
使脚本以任何非零状态退出时立即退出。
如果要继续执行,则需要捕获退出状态(137)。
/opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash -xe
rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
status=`/sbin/status nginx`
if [[ $status = *"start/running"* ]]; then
set +e
service nginx stop
exitStatus = $?
if [ $exitStatus -ne 0 ] && [ $exitStatus -ne 137 ]
then
exit $exitStatus
fi
set -e
fi
service nginx start
答案 2 :(得分:0)
事件的顺序对我来说是这样的:
/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
因此,如果您尝试删除的文件可能不存在,则部署后脚本失败并不令我感到惊讶。
我会尝试以下两种方法之一:
99_kill_default_nginx.sh
脚本,然后删除整个容器命令部分。rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
脚本中删除行99_kill_default_nginx.sh
。答案 3 :(得分:0)
/sbin/status nginx
似乎不再起作用。我将脚本更新为使用service nginx status
:
/opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash -xe
rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
status=$(service nginx status)
if [[ "$status" =~ "running" ]]; then
echo "stopping nginx..."
stop nginx
echo "starting nginx..."
start nginx
else
echo "nginx is not running... starting it..."
start nginx
fi
错误的脚本仍然在亚马逊的文档中……我不知道他们何时打算对其进行修复。时间已经足够了