为什么即使我没有更新任何代码到服务器,我也需要每天重启gunicorn

问题描述 投票:0回答:1

我正在使用Nginx和Gunicorn来提供烧瓶应用程序。一切正常,唯一的问题是,我需要在几个小时后重新启动gunicorn,或者我还没有向服务器更新任何代码。这是我遵循的步骤。

项目的根目录中的Step-1 wsgi.py文件。

from myproject import app

if __name__ == "__main__":
    app.run()

[Step-2已通过服务器验证,并且正在运行以下命令

  • python app.py
  • gunicorn --bind 0.0.0.0:5000 wsgi:app

第3步设置gunicorn服务:/etc/systemd/system/gunicorn.service

[Unit]
Description=Gunicorn API
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/var/www/api-setup
Environment="PATH=/var/www/api-setup/venv/bin"
ExecStart=/var/www/api-setup/venv/bin/gunicorn --workers 1 --bind unix:app.sock -m 007 wsgi:app

[Install]
WantedBy=multi-user.target

Step-4:nginx conf文件:/ etc / nginx / site-available / my-nginx-conf

server {
  listen 80;

  client_max_body_size 1008M;

  server_name 3.136.23.149;

  root /var/www/api-setup/;

  location / {
   proxy_pass http://unix:/var/www/api-setup/app.sock;
  }
}

几个小时后,当我请求服务器时,它返回“内部服务器错误并运行后]”>

sudo systemctl1 restart gunicorn

一切正常。任何想法都会得到应用。

谢谢!

我正在使用Nginx和Gunicorn来提供烧瓶应用程序。一切正常,唯一的问题是,我需要在几个小时后重新启动gunicorn,或者我还没有向服务器更新任何代码。这是...

python-3.x nginx gunicorn flask-restful
1个回答
0
投票

您的代码看起来不错!

© www.soinside.com 2019 - 2024. All rights reserved.