服务启动请求重复太快,拒绝启动


14

我已经在Debian 8.6上创建了一个服务,并且当我尝试使用service命令启动它时,出现错误。

我已经尝试过systemctl daemon-reload,但仍然得到相同的结果。

$ sudo service cloud9 start
$ sudo service cloud9 status
● cloud9.service - cloud9
   Loaded: loaded (/etc/systemd/system/cloud9.service; enabled)
   Active: failed (Result: start-limit) since Thu 2016-10-13 07:21:02 UTC; 2s ago
  Process: 2610 ExecStart=/opt/bitnami/nodejs/bin/node /home/user/c9sdk/server.js -w /home/user -l 0.0.0.0 -a admin:admin (code=exited, status=216/GROUP)
 Main PID: 2610 (code=exited, status=216/GROUP)

Oct 13 07:21:02 test-vm systemd[1]: cloud9.service: main process exited, code=exited, status=216/GROUP
Oct 13 07:21:02 test-vm systemd[1]: Unit cloud9.service entered failed state.
Oct 13 07:21:02 test-vm systemd[1]: cloud9.service holdoff time over, scheduling restart.
Oct 13 07:21:02 test-vm systemd[1]: Stopping cloud9...
Oct 13 07:21:02 test-vm systemd[1]: Starting cloud9...
Oct 13 07:21:02 test-vm systemd[1]: cloud9.service start request repeated too quickly, refusing to start.
Oct 13 07:21:02 test-vm systemd[1]: Failed to start cloud9.
Oct 13 07:21:02 test-vm systemd[1]: Unit cloud9.service entered failed state.

配置位于/etc/systemd/system/cloud9.service

[Unit]
Description=cloud9

[Service]
ExecStart=/opt/bitnami/nodejs/bin/node /home/user/c9sdk/server.js -w /home/user -l 0.0.0.0 -a admin:admin
Restart=always
User=nobody
Group=nobody
Environment=PATH=/bin:/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/home/user/c9sdk

[Install]
WantedBy=multi-user.target

1
如果systemctl打印的错误不是很清楚,则可能是由于根本原因被吞没并掩盖为启动失败。找出失败原因的一种可能有用的方法是,仅手动运行ExecStart指令中指定的命令。就我而言,根本原因突然出现在我身上。
Ubunfu

Answers:


6
2610 ExecStart = / opt / bitnami / nodejs / bin / node /home/user/c9sdk/server.js -w / home / user -l 0.0.0.0 -a admin:admin(代码=已退出,状态= 216 /组)
…
10月13日07:21:02 test-vm systemd [1]:cloud9.service:主进程已退出,代码=已退出,状态= 216 / GROUP

……描述了问题所在。您的组nobody不是系统上的有效组。指定一个有效的组。

环境= PATH = / bin:/ usr / bin:/ usr / local / bin

这可能是不必要的。

-w / home /用户-l 0.0.0.0

在更好的环境中,这里的cloud9服务程序将以开放文件描述符的形式接收其侦听套接字,并继承其工作目录(具有讽刺意味的是,您在该单元的其他位置显式设置了该目录)。

进一步阅读


2

删除Restart参数并添加有效的用户/组可以帮助我解决问题。

[Unit]
Description=cloud9

[Service]
ExecStart=/opt/bitnami/nodejs/bin/node /home/user/c9sdk/server.js -w /home/user -l 0.0.0.0 -a admin:admin
User=user
Group=group
Environment=PATH=/bin:/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/home/user/c9sdk

[Install]
WantedBy=multi-user.target
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.