Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Python Flask服务文件未启动_Linux_Python 3.x_Flask_Raspberry Pi_Uwsgi - Fatal编程技术网

Linux Python Flask服务文件未启动

Linux Python Flask服务文件未启动,linux,python-3.x,flask,raspberry-pi,uwsgi,Linux,Python 3.x,Flask,Raspberry Pi,Uwsgi,我写了一个小程序。这个应用程序运行得很好。然而,我试图创建一个服务文件,却遇到了一些问题。运行命令sudo-uwsgi-uwsgi.ini。应用程序启动。 我创建了一个服务文件 [Unit] Description=uWsgi instance to start relay site After=network.target [Service] User=pi Group=pi WorkingDirectory=/var/www/relay ExecStart=sudo uwsgi uwsgi

我写了一个小程序。这个应用程序运行得很好。然而,我试图创建一个服务文件,却遇到了一些问题。运行命令
sudo-uwsgi-uwsgi.ini
。应用程序启动。 我创建了一个服务文件

[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
服务文件在我尝试启动时出错

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.

它说
可执行路径不是绝对的
,因为可执行文件是
sudo
而不是
/usr/bin/sudo
。Systemd需要完整路径,因为它不像使用终端时那样使用shell

另外,如果您要使用
sudo
命令,那么您最好使用
root
作为用户(这是默认设置)。像这样的方法应该会奏效:

[Service]
WorkingDirectory=/var/www/relay
ExecStart=/absolute/path/to/uwsgi uwsgi.ini

您可以运行
which-uwsgi
查找到
uwsgi
的绝对路径,谢谢您的帮助和信息。