首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Python Flask服务文件未启动

Python Flask服务文件未启动
EN

Stack Overflow用户
提问于 2019-04-01 02:31:27
回答 1查看 844关注 0票数 0

我写了一个小应用。这个应用程序运行得很好。然而,我正在尝试创建一个服务文件,并且我遇到了问题。运行命令sudo uwsgi uwsgi.ini会起作用。应用程序启动。我创建了一个服务文件。

代码语言:javascript
复制
[Unit]
Description=uWsgi instance to start relay site
After=network.target

[Service]
User=pi
Group=pi
WorkingDirectory=/var/www/relay
ExecStart=sudo uwsgi uwsgi.ini

[Install]
WantedBy=multi-user.target

当我尝试启动服务文件时,它会出错。

代码语言:javascript
复制
Loaded: error (Reason: Invalid argument)
relay.service: Unit entered failed state.
relay.service: Failed with result 'exit-code'.
[/etc/systemd/system/relay.service:11] Executable path is not absolute, ignoring: uwsgi uwsgi.ini
relay.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
[/etc/systemd/system/relay.service:9] Executable path is not absolute, ignoring: sudo uwsgi uwsgi.ini
relay.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-01 02:45:00

它之所以使用Executable path is not absolute,是因为可执行文件是sudo而不是/usr/bin/sudo。Systemd需要完整路径,因为它不像您使用终端时那样使用shell。

此外,如果您打算使用sudo命令,那么您也可以以用户的身份使用root (这是默认设置)。像这样的东西应该是有效的:

代码语言:javascript
复制
[Service]
WorkingDirectory=/var/www/relay
ExecStart=/absolute/path/to/uwsgi uwsgi.ini

您可以运行which uwsgi来查找uwsgi的绝对路径。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55444108

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档