Python Flask 服务文件未启动
Python Flask Service file is not starting
我写了一个小应用程序。该应用程序运行良好。但是,我正在尝试创建一个服务文件,但我 运行 遇到了问题。 运行 命令 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.
它说 Executable path is not absolute
因为可执行文件是 sudo
而不是 /usr/bin/sudo
。 Systemd 需要完整路径,因为它不像您使用终端时那样使用 shell。
此外,如果您要执行 sudo
命令,那么您也可以使用 root
作为用户(默认设置)。这样的事情应该有效:
[Service]
WorkingDirectory=/var/www/relay
ExecStart=/absolute/path/to/uwsgi uwsgi.ini
您可以运行which 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.
它说 Executable path is not absolute
因为可执行文件是 sudo
而不是 /usr/bin/sudo
。 Systemd 需要完整路径,因为它不像您使用终端时那样使用 shell。
此外,如果您要执行 sudo
命令,那么您也可以使用 root
作为用户(默认设置)。这样的事情应该有效:
[Service]
WorkingDirectory=/var/www/relay
ExecStart=/absolute/path/to/uwsgi uwsgi.ini
您可以运行which uwsgi
找到uwsgi
的绝对路径。