uWSGI 的 Systemd 单元文件失败

uWSGI 的 Systemd 单元文件失败

使用 Flask、NGINX 和 uWSGI,我已成功设置了一个应用程序,用于通过 Twilio 发送和接收短信。一切都运行正常,只是它在我的个人用户帐户(名为 trinitrogen)下运行。我想将其移动到其他用户帐户(名为 apps)下运行,但遇到了 systemd 单元文件问题。我遇到的最大困难是,我甚至找不到错误的良好日志,所以我不知道从哪里开始

首先,我的作品基于本教程大部分都成功了,正是共享的内容

我创建了新用户并将其添加到 wheel

[apps@argon ~]$ groups
apps wheel

将 repo 克隆到应用程序主目录中,在目录中设置一个名为 venv 的虚拟环境,安装所有 python 包,在命令行中成功测试 uwsgi

[apps@argon PowderMonitor]$ uwsgi --socket 10.0.0.221:8080 --protocol=http -w wsgi:app

效果很好。我继续设置 systemd 文件,但在这里我遇到了障碍。下面是当前文件,以及尝试重新启动服务后的输出。

[apps@argon PowderMonitor]$ cat /etc/systemd/system/TwilioApp.service
[Unit]
Description=uWSGI - TwilioApp - apps acccount
After=network.target

[Service]
User=apps
Group=nginx
WorkingDirectory=/home/apps/PowderMonitor
Environment="PATH=/home/apps/PowderMonitor/venv/bin"
ExecStart=/home/apps/PowderMonitor/venv/bin/uwsgi --ini TwilioApp.ini

[Install]
WantedBy=multi-user.target
[apps@argon PowderMonitor]$ sudo systemctl restart TwilioApp.service
[apps@argon PowderMonitor]$ sudo systemctl status TwilioApp.service -l
● TwilioApp.service - uWSGI - TwilioApp - apps acccount
   Loaded: loaded (/etc/systemd/system/TwilioApp.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2017-04-14 16:35:52 CDT; 3s ago
  Process: 3420 ExecStart=/home/apps/PowderMonitor/venv/bin/uwsgi --ini TwilioApp.ini (code=exited, status=1/FAILURE)
 Main PID: 3420 (code=exited, status=1/FAILURE)

Apr 14 16:35:52 argon.xxx systemd[1]: Started uWSGI - TwilioApp - apps acccount.
Apr 14 16:35:52 argon.xxx systemd[1]: Starting uWSGI - TwilioApp - apps acccount...
Apr 14 16:35:52 argon.xxx systemd[1]: TwilioApp.service: main process exited, code=exited, status=1/FAILURE
Apr 14 16:35:52 argon.xxx systemd[1]: Unit TwilioApp.service entered failed state.
Apr 14 16:35:52 argon.xxx systemd[1]: TwilioApp.service failed.
[apps@argon PowderMonitor]$

下面是 TwilioApp.service 文件的示例,它在我的 trinitrogen 帐户下完美运行。请注意,我唯一更改的是用户和 3 个目录中的内容

[trinitrogen@argon PowderMonitor]$ cat TwilioApp.service.example
[Unit]
Description=uWSGI instance to serve TwilioApp
After=network.target

[Service]
User=trinitrogen
Group=nginx
WorkingDirectory=/home/trinitrogen/Python/PowderMonitor
Environment="PATH=/home/trinitrogen/Python/PowderMonitor/venv/bin"
ExecStart=/home/trinitrogen/Python/PowderMonitor/venv/bin/uwsgi --ini TwilioApp.ini

[Install]
WantedBy=multi-user.target

下面是用于 uwsgi 的 TwilioApp.ini,它与我在“trinitrogen”帐户下成功运行的版本以及我的“apps”帐户下的版本完全相同。

[apps@argon PowderMonitor]$ cat TwilioApp.ini
[uwsgi]
module = wsgi:app

master = true
processes = 5

socket = TwilioApp.sock
chmod-socket = 664
vacuum = true
#location of log files
logto = /var/log/uwsgi/TwilioApp.log
die-on-term = true

相关内容