【问题标题】:Systemd + PM2 issue - PM2 path gives errorSystemd + PM2 问题 - PM2 路径给出错误
【发布时间】: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


    【解决方案1】:

    pm2 是一个与 npm 一起运行的应用程序。你不能告诉 pm2 启动 npm。

    pm2 查找项目的入口点。

    试试这样的:

    pm2 start app.js
    

    【讨论】:

    猜你喜欢
    • 2019-11-18
    • 2020-01-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多