从systemd启动gunicorn服务器时发生Gevent not installed错误

2024-03-29 07:13:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个运行ubuntu的EC2实例。它通过gunicorn提供烧瓶应用程序。我希望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)

Tags: ipapplicationlibusrlocalservicecodegevent