Python uwsgi作为系统服务运行时管道破裂

Python uwsgi作为系统服务运行时管道破裂,python,linux,uwsgi,systemd,conda,Python,Linux,Uwsgi,Systemd,Conda,我正在使用python 2.7.11在conda虚拟环境中运行uwsgi/flask python应用程序 我正在从CentOS 6迁移到CentOS 7,并希望利用systemd将我的应用程序作为服务运行。如果我手动调用我的应用程序的启动脚本(sh start foo.sh),一切(配置和代码)都可以正常工作,但当我尝试将其作为systemd服务启动(sudo systemctl foo start)时,它会启动应用程序,但随后立即失败,并出现以下错误: WSGI app 0 (mountpo

我正在使用python 2.7.11在conda虚拟环境中运行uwsgi/flask python应用程序

我正在从CentOS 6迁移到CentOS 7,并希望利用systemd将我的应用程序作为服务运行。如果我手动调用我的应用程序的启动脚本(
sh start foo.sh
),一切(配置和代码)都可以正常工作,但当我尝试将其作为systemd服务启动(
sudo systemctl foo start
)时,它会启动应用程序,但随后立即失败,并出现以下错误:

WSGI app 0 (mountpoint='') ready in 8 seconds on interpreter 0x14c38d0 pid: 3504 (default app)
mountpoint  already configured. skip.
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 3504)
emperor_notify_ready()/write(): Broken pipe [core/emperor.c line 2463]
VACUUM: pidfile removed.
这是我的systemd单位文件:

[Unit]
Description=foo

[Service]
ExecStart=/bin/bash /app/foo/bin/start-foo.sh
ExecStop=/bin/bash /app/foo/bin/stop-foo.sh

[Install]
WantedBy=multi-user.target
不确定是否有必要,但以下是我的uwsgi皇帝和附庸配置:

皇帝

[uwsgi]
emperor = /app/foo/conf/vassals/
daemonize = /var/log/foo/emperor.log
附庸

[uwsgi]
http-timeout = 500
chdir = /app/foo/scripts
pidfile = /app/foo/scripts/foo.pid
#socket = /app/foo/scripts/foo.soc
http = :8888
wsgi-file = /app/foo/scripts/foo.py
master = 1
processes = %(%k * 2)
threads = 1
module = foo
callable = app
vacuum = True
daemonize = /var/log/foo/uwsgi.log
我试图用谷歌搜索这个问题,但似乎找不到任何相关的东西。我怀疑这与在虚拟环境中运行uwsgi并使用systemctl启动它有关。我是systemd n00b,所以如果我在单位文件中出错,请告诉我


这不是一个拦截器,因为我仍然可以通过手动执行脚本来启动/停止我的应用程序,但我希望能够将其作为服务运行,并在启动时使用systemd自动启动它。

按照uwsgi文档中关于设置systemd服务的说明修复了该问题

以下是我所改变的:

从皇帝和附庸配置中删除了
daemonize

从上面的链接中获取单位文件,并稍加修改以使用我的应用程序

[Unit]
Description=uWSGI Emperor
After=syslog.target

[Service]
ExecStart=/app/foo/bin/uwsgi /app/foo/conf/emperor.ini
RuntimeDirectory=uwsgi
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target

尝试使用
Type=simple
WorkingDirectory=/app/foo/bin/
@Noelkd将
Type
WorkingDirectory
添加到
Service
单元文件的
[Service]
部分,没有帮助。。。同样的问题。