【发布时间】:2020-07-17 05:46:51
【问题描述】:
通过“npm start”和 PM2 (pm2 start npm -- start) 成功运行的 node.js 应用程序不作为 systemctl 服务运行。
谁能帮帮我,好吗?
journalctl -xe
Jul 16 18:30:05 test.com systemd[7420]: systems.bbb.service: Failed to execute command: No such file or directory
Jul 16 18:30:05 test.com systemd[7420]: systems.bbb.service: Failed at step EXEC spawning /usr/local/bin/pm2 start npm -- start: No such file or directory
-- Subject: Process /usr/local/bin/pm2 start npm -- start could not be executed
which pm2
/usr/local/bin/pm2
在 systemd 文件中指定了一个 env 文件,该配置适用于基于 Go 的服务。 systems.bbb.service 文件:
[Unit]
Description=Systems backend service
After=syslog.target network.target network-online.target
Requires=mongod.service
[Service]
Type=simple
WorkingDirectory=/root/bbb/git-repos/bbb
ExecStart="/usr/local/bin/pm2 start npm -- start"
Restart=on-failure
User=root
EnvironmentFile=/root/bbb/git-repos/bbb/env
[Install]
WantedBy=multi-user.target
【问题讨论】:
标签: node.js npm systemd pm2 systemctl