【问题标题】:Systemd does not activate service?Systemd没有激活服务?
【发布时间】:2021-09-05 06:58:36
【问题描述】:

我需要让 systemd 上的服务保持运行,因为它没有激活?由于我遵循documentation的建议,为什么会发生这种情况,以下是代码:

服务代码:

# Contents of /etc/systemd/system/quark.service
[Unit]
Description=Quark
After=network.target

[Service]
Type=simple
User=cto
ExecStart=/usr/local/bin/python3.9 /var/net/
Restart=always

[Install]
WantedBy=multi-user.target

状态码:

● quark.service - Quark
   Loaded: loaded (/etc/systemd/system/quark.service; enabled; vendor preset: en
   Active: failed (Result: exit-code) since Mon 2021-06-21 15:20:34 UTC; 8s ago
  Process: 1467 ExecStart=/usr/local/bin/python3.9 /var/net/ (code=exited, statu
 Main PID: 1467 (code=exited, status=1/FAILURE)

Jun 21 15:20:34 webstrucs systemd[1]: quark.service: Main process exited, code=e
Jun 21 15:20:34 webstrucs systemd[1]: quark.service: Failed with result 'exit-co
Jun 21 15:20:34 webstrucs systemd[1]: quark.service: Service RestartSec=100ms ex
Jun 21 15:20:34 webstrucs systemd[1]: quark.service: Scheduled restart job, rest
Jun 21 15:20:34 webstrucs systemd[1]: Stopped Quark.
Jun 21 15:20:34 webstrucs systemd[1]: quark.service: Start request repeated too 
Jun 21 15:20:34 webstrucs systemd[1]: quark.service: Failed with result 'exit-co
Jun 21 15:20:34 webstrucs systemd[1]: Failed to start Quark.

【问题讨论】:

  • 您的服务抱怨启动请求太快。是否配置正确?老实说,我个人不了解 Quark,但如果是重试/重启率,您可能想要更改的选项是 RestartSec。这是一个相关的帖子:stackoverflow.com/a/39284869

标签: linux debian systemd debian-buster


【解决方案1】:

ExecStart 应该是要执行的命令:

systemd manpages:

ExecStart=

Commands with their arguments that are executed when this service is started.

这一节:

ExecStart=/usr/local/bin/python3.9 /var/net/

应该是:

ExecStart=/usr/local/bin/python3.9 path_to_python_script.py

【讨论】:

    猜你喜欢
    • 2021-04-10
    • 2015-10-20
    • 2014-04-25
    • 1970-01-01
    • 2020-05-21
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    相关资源
    最近更新 更多