从systemd启动gunicorn服务器时,出现Gevent未安装的错误。

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

我有一个运行ubuntu的EC2实例。它通过gunicorn为flask应用提供服务。我想让gunicorn服务器在EC2实例通过systemd重启时自动启动,使用以下.service文件。

[Unit]
Description="gunicorn server for rayaan "

[Service]
WorkingDirectory=/home/ubuntu/webClient
Type=simple
ExecStart=/usr/local/bin/gunicorn --worker-class gthread -k gevent --worker-connections 1000 --workers 10 --threads 20  --log-level DEBUG --bind 0.0.0.0:7777 application:application


[Install]
WantedBy=multi-user.target

然后我运行这些来检查它是否有效

systemctl daemon-reload
systemctl start rayaanWebCli
systemctl status rayaanWebCli

状态的输出。

rayaanWebCli.service - "gunicorn server for rayaan "
   Loaded: loaded (/lib/systemd/system/rayaanWebCli.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2019-12-09 13:31:54 UTC; 15min ago
  Process: 1776 ExecStart=/usr/local/bin/gunicorn --worker-class gthread -k gevent --worker-connections 1000 --workers 10 --threads 20 --log-level DEBUG --bind 0.0.0.0:7777 application:applicatio
 Main PID: 1776 (code=exited, status=1/FAILURE)

Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]:   File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 135, in load_class
Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]:     mod = import_module('.'.join(components))
Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]:   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]:     __import__(name)
Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]:   File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/ggevent.py", line 22, in <module>
Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]:     raise RuntimeError("You need gevent installed to use this worker.")
Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]: RuntimeError: You need gevent installed to use this worker.
Dec 09 13:31:54 ip-172-31-8-1 gunicorn[1776]: ]
Dec 09 13:31:54 ip-172-31-8-1 systemd[1]: rayaanWebCli.service: Main process exited, code=exited, status=1/FAILURE
Dec 09 13:31:54 ip-172-31-8-1 systemd[1]: rayaanWebCli.service: Failed with result 'exit-code'.
lines 1-16/16 (END)
python flask gunicorn gevent
1个回答
0
投票

要解决这个问题,你需要安装gevent python包,你可以使用下面的命令。

pip install gevent

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