我正在尝试将 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'.
这是什么错误?我该如何解决这个问题?
我想运行该脚本,sudo
因为脚本的一部分需要管理员权限。
答案1
可能更正确的答案是:
systemctl reset-failed servicename.service
取自https://serverfault.com/questions/930047/how-to-bypass-systemd-start-request-repeated-too-quickly
答案2
当您遇到start-limit-hit
或Start request repeated too quickly
可能是由于Restart=on-failure
服务定义中的指令导致时。很有可能,错误有一个初始原因,但它隐藏在您看到的背后。
找出答案:(显然,用你的服务替换 carbon-relay-ng)
- 跑步
systemctl status carbon-relay-ng
- 找到服务加载的源(第一张图片)
nano /lib/systemd/system/carbon-relay-ng.service
- 删除行
Restart=on-failure
并保存文件(第二张图) - 跑步
systemctl restart carbon-relay-ng
- 运行
systemctl status carbon-relay-ng
检查真正的错误
真实错误
答案3
跑步
mkdir /var/run/sshd
然后
systemctl restart ssh
:竖起大拇指:
完毕!
答案4
我也遇到了同样的错误。这是由于应用程序反复重新启动而发生的。在我的场景中,我的应用程序没有以 systemd 服务的形式运行,而是以恶魔模式运行。检查您的应用程序是否以demon
或 的形式运行systemd
。