首页 > 解决方案 > Gunicorn Elastic Beanstalk 更改超时

问题描述

我正在尝试在 Python 3.7 Amazon Linux 2(版本 3.1)Elastic Beanstalk 部署上更改 Gunicorn 的超时。我的 Procfile 看起来像:

web: gunicorn --bind :8000 --workers 3 --threads 2 --timeout 300 application.application:application

但我似乎仍然得到默认的 30 秒超时。

我在 .ebextensions 中的 nginx 配置如下所示:

files:
  "/etc/nginx/conf.d/timeout.conf" :
    mode: "000644"
    owner: root
    group: root
    content: |
      keepalive_timeout 600;
      proxy_connect_timeout 600;
      proxy_send_timeout 600;
      proxy_read_timeout 600;
      send_timeout 600; 
      fastcgi_send_timeout 600; 
      fastcgi_read_timeout 600;

任何帮助,将不胜感激。

标签: amazon-web-servicesflaskamazon-elastic-beanstalkgunicorn

解决方案


由于您使用的是 Amazon Linux 2 (AL2),因此不支持nginx通过设置选项。这可以解释为什么它们没有任何效果。/etc/nginx/conf.d/timeout.conf

对于 AL2,使用此处显示的文件夹nginx设置设置。.platform/nginx/conf.d/

因此,您可以尝试以下方法。有一个.platform/nginx/conf.d/myconfig.conf包含以下内容的文件:

keepalive_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600; 
fastcgi_send_timeout 600; 
fastcgi_read_timeout 600;

推荐阅读