AWS Beanstalk-更新环境变量时Python应用程序失败

时间:2018-10-30 16:58:05

标签: python amazon-web-services amazon-elastic-beanstalk

我正在使用AWS Elastic beantalk来提供自定义python应用程序。除更新环境变量外,其他所有操作均正常。

如果我尝试通过eb setenv FOO=bar进行更改(或在控制台中进行更改),则应用程序将停止识别 all 所有env变量。重新启动服务器或发送新的部署可以解决该问题,但是客户端可能会遇到停机或400/500错误。

我几乎确定我需要使用configdeploy挂钩,但是不知道如何使用。

谢谢!


配置:

在64位Amazon Linux / 2.7.3上运行的Python 3.4

0_python.config

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: 'configs/wsgi.py'
    NumProcesses: 6
    NumThreads: 15
container_commands:
  01_wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'
  02_traceenable:
    command: 'echo "TraceEnable Off" >> ../wsgi.conf'

1_apache.config

container_commands:
  01_setup_apache:
    command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
files:
  "/etc/httpd/conf.d/ssl_rewrite.conf":
    mode: "000644"
    owner: root
    group: root
    content:    |
      RewriteEngine On
        <If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
          RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
        </If>
  "/etc/httpd/conf.d/wsgi_custom.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      WSGIApplicationGroup %{GLOBAL}

1 个答案:

答案 0 :(得分:0)

您可以使用{p>在.config文件中设置环境变量

option_settings: aws:elasticbeanstalk:application:environment: FOO: bar