通过 systemd 添加 supervisord 运行时出错

通过 systemd 添加 supervisord 运行时出错

我正在尝试从 systemd 运行主管,并正在遵循本教程这里

创建此文件后,/etc/systemd/system/supervisord.service其内容如下:

[Unit]
Description=Supervisor daemon
Documentation=http://supervisord.org
After=network.target

[Service]
ExecStart=/usr/local/bin/supervisord -n -c /etc/supervisor/supervisord.conf
ExecStop=/usr/local/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/local/bin/supervisorctl $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target
Alias=supervisord.service

当我运行它时出现以下错误:

Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: Started Supervisor daemon.
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[8772]: supervisord.service: Failed to execute command: No such file or directory
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[8772]: supervisord.service: Failed at step EXEC spawning /usr/local/bin/supervisord: No such file or directory
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Main process exited, code=exited, status=203/EXEC
Mar 17 01:18:22 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Failed with result 'exit-code'.
Mar 17 01:19:04 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Service hold-off time over, scheduling restart.
Mar 17 01:19:04 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: supervisord.service: Scheduled restart job, restart counter is at 1.
Mar 17 01:19:04 ubuntu-s-1vcpu-1gb-nyc3-01 systemd[1]: Stopped Supervisor daemon.

显然,它说没有这样的目录,但创建一个目录实际上是解决问题的正确方法吗?

我不确定的原因是因为在查看其他(我猜)类似的问题时(例如:这里),他们似乎以不同的方式修复了这个问题。此外,在教程中,除了的内容之外,它没有在其他地方提到这条路径(不存在的路径)supervisord.service,所以我很困惑这里发生了什么。

有人可以向我解释或指出一些具体的内容以便以正确的方式解决我的问题吗?

谢谢!

更新

locate supervisord产量:

/etc/supervisor/supervisord.conf
/etc/systemd/system/supervisord.service
/usr/bin/echo_supervisord_conf
/usr/bin/supervisord
/usr/lib/python2.7/dist-packages/supervisor/supervisord.py
/usr/lib/python2.7/dist-packages/supervisor/supervisord.pyc
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisord.py
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisord.pyc
/usr/share/man/man1/echo_supervisord_conf.1.gz
/usr/share/man/man1/supervisord.1.gz
/var/log/supervisor/supervisord.log

locate supervisorctl产量:

/usr/bin/supervisorctl
/usr/lib/python2.7/dist-packages/supervisor/supervisorctl.py
/usr/lib/python2.7/dist-packages/supervisor/supervisorctl.pyc
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisorctl.py
/usr/lib/python2.7/dist-packages/supervisor/tests/test_supervisorctl.pyc
/usr/share/man/man1/supervisorctl.1.gz

答案1

您的服务文件为二进制文件指定了错误的位置。

在文件中,更改

/usr/local/bin/supervisord

/usr/bin/supervisord

/usr/local/bin/supervisorctl 

/usr/bin/supervisorctl 

接下来,运行命令systemctl daemon-reload,然后systemctl start supervisord

答案2

您实际上并没有按照该教程通过 easy_install 安装 Supervisor 包;它是从 Ubuntu 包安装的。该包已包含一个 systemd 单元supervisor.service,您可以直接启动它。您无需创建自己的单元。

该教程也很糟糕,因为它没有解释为什么他们做出了奇怪的决定。我会扔掉该教程并使用您已有的现有主管单元。

当然,我也会抛弃 Supervisord,因为它是多余的;它所做的几乎所有事情都由 systemd 覆盖(甚至更好)。我还会抛弃引导您尝试安装 Supervisord 的任何教程。

相关内容