小编doo*_*ers的帖子

Systemd .service 文件不起作用

我正在尝试使用 systemd 在系统启动时自动运行以下命令。

/usr/bin/node /var/www/html/rest-api/dist/index.js

我已经通过手动运行来验证该命令是否有效,但是当我尝试使用rest.service文件启动它时,我遇到了错误。

休息服务:

[Unit]
Description=REST API
After=network.target

[Service]
ExecStart=/usr/bin/node /var/www/html/rest-api/dist/index.js
Restart=always
User=nobody
Group=nobody
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/var/www/rest-api/dist

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

journalctl -u rest-api 输出:

其中rest.service用户和组 = 无人:

Oct 06 02:10:28 ip-172-31-26-208 systemd[7172]: rest-api.service: Failed at step GROUP spawning /usr/bin/node: No such process
Oct 06 02:10:28 ip-172-31-26-208 systemd[1]: rest-api.service: Main process exited, code=exited, status=216/GROUP
Oct 06 02:10:28 ip-172-31-26-208 systemd[1]: rest-api.service: Unit entered failed state.
Oct 06 02:10:28 ip-172-31-26-208 systemd[1]: rest-api.service: Failed with result 'exit-code'.
Oct …
Run Code Online (Sandbox Code Playgroud)

nodejs systemd

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

nodejs ×1

systemd ×1