如何解决“服务启动限制命中”

Mat*_*hew 21 sudo services nodejs systemd

我正在尝试将 Node.js API 作为服务运行,但遇到了问题。

运行时systemctl status servicename.service出现以下错误:

servicename.service - [Service description]  
Loaded: leaded (/etc/systemd/system/servicename.service; enabled; vendor preset: enabled)  
Active: failed (Result: start-limit-hit) since [timestamp] ago  
Process: 1142 ExecStart=/usr/bin/node /home/pi/Documents/server.js (code=exited, status=0/SUCCESS)  
Main PID: 1142 (code=exited, status=0/SUCCESS)  
[timestamp] hostname systemd[1]: servicename.service: Service hold-off time over, scheduling restart.  
[timestamp] hostname systemd[1]: Stopped [Service description]
[timestamp] hostname systemd[1]: servicename.service: Start request repeated too quickly.  
[timestamp] hostname systemd[1]: Failed to start [Service description]
[timestamp] hostname systemd[1]: servicename.service: Unit entered failed state.  
[timestamp] hostname systemd[1]: servicename.service: Failed with result 'start-limit-hit'.
Run Code Online (Sandbox Code Playgroud)

这是什么错误,我该如何解决这个问题?

我想运行脚本,sudo因为脚本的一部分需要管理员权限。

小智 18

可能是更正确的答案:

systemctl reset-failed servicename.service

取自https://serverfault.com/questions/930047/how-to-bypass-systemd-start-request-repeated-too-quickly


ago*_*dev 14

当您有start-limit-hitStart request repeated too quickly可能是由于Restart=on-failure服务定义中的指令所致。错误的最初原因很可能是有的,但它隐藏在您看到的原因背后。

要找出答案:(显然,用您的服务替换carbon-relay-ng)

  1. 跑步systemctl status carbon-relay-ng
  2. 找到加载服务的源(第一张图片)
  3. nano /lib/systemd/system/carbon-relay-ng.service
  4. 删除行Restart=on-failure并保存文件(第二张图片)
  5. 跑步systemctl restart carbon-relay-ng
  6. 运行systemctl status carbon-relay-ng检查实际错误

寻找路径

开放服务定义

真实错误

对我来说,它显示了以下错误,我必须通过设置文件权限来纠正该错误: 真实错误


小智 10

mkdir /var/run/sshd

然后

systemctl restart ssh

:竖起大拇指:

完毕!

  • 这个问题与 sshd 有什么关系? (7认同)
  • 作为参考 [SSH 服务器在重启后停止工作,由于缺少 /var/run/sshd](https://askubuntu.com/a/1110843/566421) (2认同)

小智 1

我也在为同样的错误而苦苦挣扎。这是由于应用程序一次又一次重新启动而发生的。在我的场景中,我的应用程序没有作为 systemd 服务运行,而是像恶魔模式一样运行。demon检查您的应用程序是否以或运行systemd