RHEL 9 Gunicorn in python虚拟环境系统服务问题

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

我正在尝试配置 gunicorn 来为我的烧瓶应用程序提供服务,并使用 NGINX 作为代理配置。此应用程序托管在 RHEL 9 服务器上。安装了 Python 3.9 和 gunicorn 20.1.0。

目前坚持尝试让 gunicorn 作为服务启动。

服务的位置是/etc/systemd/system/gunicorn.service,配置如下:

[Unit]
Description=Gunicorn instance to serve Flask app
After=network.target

[Service]
User=testuser
Group=testuser
WorkingDirectory=/home/testuser/webapp
Environment="PATH=/home/testuser/env/vwebapp/bin"
ExecStart=/home/testuser/env/vwebapp/bin/gunicorn --chdir /home/testuser/webapp --config /home/testuser/webapp/gunicorn.py  app:app

[Install]
WantedBy=multi-user.target

这是我收到的错误:

Apr 08 01:09:50 TEST gunicorn[265951]: All git commands will error until this is rectified.
Apr 08 01:09:50 TEST gunicorn[265951]: This initial warning can be silenced or aggravated in the future by setting the
Apr 08 01:09:50 TEST gunicorn[265951]: $GIT_PYTHON_REFRESH environment variable. Use one of the following values:
Apr 08 01:09:50 TEST gunicorn[265951]:     - quiet|q|silence|s|none|n|0: for no warning or exception
Apr 08 01:09:50 TEST gunicorn[265951]:     - warn|w|warning|1: for a printed warning
Apr 08 01:09:50 TEST gunicorn[265951]:     - error|e|raise|r|2: for a raised exception
Apr 08 01:09:50 TEST gunicorn[265951]: Example:
Apr 08 01:09:50 TEST gunicorn[265951]:     export GIT_PYTHON_REFRESH=quiet
Apr 08 01:09:50 TEST systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Apr 08 01:09:50 TEST systemd[1]: gunicorn.service: Failed with result 'exit-code'.

作为参考,这是我用于测试的 gunicorn 配置文件:

bind = "0.0.0.0:8080"
graceful_timeout = 3000
limit_request_line = 0
loglevel = "debug"
preload_app = True
raw_env = ["TERM=screen"]
timeout = 3000
workers = 5

让 gunicorn 系统服务正常工作一直是我在整个过程中的首要问题。无论出于何种原因,我都能够在 ExecStart 中手动运行相同的参数“--chdir /home/testuser/webapp --config /home/testuser/webapp/gunicorn.py app:app”,gunicorn 启动时没有任何问题。任何帮助将不胜感激。

我已经尝试了 gunicorn.service 配置示例的几种变体(包括省略 --chdir 和 --config 参数),但仍然没有让这项服务正常工作。

我最终希望能够将我的 gunicorn python 配置文件作为参数传递到自定义 gunicorn 服务的 ExecStart 部分。

flask service gunicorn python-3.9 rhel9
© www.soinside.com 2019 - 2024. All rights reserved.