2016-11-23 66 views
2

我一直在使用EBS,沒有任何問題。今天,我已經添加負載均衡器,並上傳了我的包具有以下配置:AWS Beanstalk命令問題

files: 
    "/etc/nginx/conf.d/proxy.conf": 
    mode: "000755" 
    owner: root 
    group: root 
    content: | 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 


container_commands: 
    01_reload_nginx: 
    command: "service nginx reload" 

然而,當我試圖啓動包,我得到以下錯誤:

Application deployment failed at 2016-11-23T14:07:40Z with exit status 7 and error: container_command 01_reload_nginx in .ebextensions/environment.config failed.

請告訴我繼續?

這些日誌:

[eb-cfn-init]: Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/pre. [eb-cfn-init]: [2016-11-23T16:09:31.193Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild] : Starting activity... [eb-cfn-init]: [2016-11-23T16:09:31.506Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity... [eb-cfn-init]: [2016-11-23T16:09:31.507Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_My_First_Elastic_Beanstalk_Application] : Starting activity... [eb-cfn-init]: [2016-11-23T16:09:31.842Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_My_First_Elastic_Beanstalk_Application/Command 01_reload_nginx] : Starting activity... [eb-cfn-init]: [2016-11-23T16:09:31.868Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_My_First_Elastic_Beanstalk_Application/Command 01_reload_nginx] : Activity execution failed, because: (ElasticBeanstalk::ExternalInvocationError) [eb-cfn-init]: [eb-cfn-init]: [eb-cfn-init]: [2016-11-23T16:09:31.868Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_My_First_Elastic_Beanstalk_Application/Command 01_reload_nginx] : Activity failed. [eb-cfn-init]: [2016-11-23T16:09:31.868Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_My_First_Elastic_Beanstalk_Application] : Activity failed. [eb-cfn-init]: [2016-11-23T16:09:31.868Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Activity failed. [eb-cfn-init]: [2016-11-23T16:09:31.884Z] INFO [2680] - [Application deployment [email protected]/StartupStage0/EbExtensionPostBuild] : Activity failed. [eb-cfn-init]: [2016-11-23T16:09:31.884Z] INFO [2680] - [Application deployment [email protected]/StartupStage0] : Activity failed. [eb-cfn-init]: [2016-11-23T16:09:31.884Z] INFO [2680] - [Application deployment [email protected]] : Completed activity. Result: [eb-cfn-init]: Application deployment - Command CMD-SelfStartup failed

回答

0

很有可能你的NGINX配置文件被破壞,沒有通過測試時,NGINX重載。在服務重新載入期間,NGINX首先檢查你的配置文件,如果配置正確,一個HUP信號被髮送到NGINX進程,該進程正常關閉老工人並用新配置啓動新工人。

爲了驗證您的配置文件,您可以使用下面的命令:

/usr/bin/nginx -t -c ~/mynginx.conf

-t =不要跑,只是測試配置文件。 NGINX檢查配置的正確語法,然後嘗試打開配置中引用的文件。

-c filename =您的配置文件的位置(如果不是默認)

你應該能夠與下面的命令也來測試你的配置(取決於你是什麼操作系統):

service nginx configtest

第一種變體是可取的,因爲它也會打印NGINX配置中的任何信息,警告和錯誤信息。

希望這會有所幫助。

+0

這怎麼可能?從字面上看,環境設置或配置文件中沒有任何變化。 – uksz

0

我在平臺升級期間發生了完全相同的問題。我就此與AWS支持部門聯繫:他們表示,他們無法複製,但有一條非常有趣的信息實際上可以防止這種情況發生。

However, [command: "sudo service nginx reload"] is not necessary as nginx service restarts automatically after every successful deployment.

所以你可以刪除腳本的

container_commands: 
    01_reload_nginx: 
    command: "service nginx reload" 

一部分,所以你再也不用重裝失敗。