Unitech / Unitech/pm2

PM2 ecosystem configs to run a service before running the node process

Open
#5,674 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

I am not able to configure a working ecosystem file for a node program which requires to run a service before executing the node program.

Basically equivalent configuration for running this command via pm2

xvfb-run -s "-ac -screen 0 1280x720x24" node app.js

How could we reproduce this issue?

  1. First install xvdf in your ubuntu 20.04 machine by running - sudo apt-get install xvfb
  2. Then run any node program xvfb-run -s "-ac -screen 0 1280x720x24" node app.js. It will work without any issue.
  3. Then try any of these configurations as ecosystem.config.js but none of them works (i.e. the process does not start)
module.exports = {
  apps : [
// This one seems to have compiled with a different version of node so crashed
{
    name   : "gl-app",
    cwd: "/home/ubuntu/.nvm/versions/node/v16.20.2/lib/node_modules/@my-org/gl-app",
    script : "cli.js",
    interpreter: "/usr/bin/xvfb-run",
    args: "-s '-ac -screen 0 1280x720x24' /home/ubuntu/.nvm/versions/node/v16.20.2/lbin/node --experimental-modules",
    env: { "MY_VAR": "test" }
},
// Neither does this one work
{
    name   : "gl-app",
    cwd: "/home/ubuntu/.nvm/versions/node/v16.20.2/lib/node_modules/@my-org/gl-app",
    script : "/home/ubuntu/.nvm/versions/node/v16.20.2/lbin/node --experimental-modules cli.js",
    interpreter: "xvfb-run -s "-ac -screen 0 1280x720x24" ",
    args: "",
    env: { "MY_VAR": "test" }
},

// Neither does this one work

{
    name   : "gl-app",
    cwd: "/home/ubuntu/.nvm/versions/node/v16.20.2/lib/node_modules/@my-org/gl-app",
    script : "xvfb-run -s '-ac -screen 0 1280x720x24'  cli.js",
    interpreter: "node@16.20.2",
    args: "--experimental-modules",
    env: { "MY_VAR": "test" }
},

// This one works but does not run `xvfb-run`

{
    name   : "gl-app",
    cwd: "/home/ubuntu/.nvm/versions/node/v16.20.2/lib/node_modules/@my-org/gl-app",
    script : "cli.js",
    interpreter: "node@16.20.2",
    args: "--experimental-modules",
    env: { "MY_VAR": "test" }
}
]

What did I miss?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the working xvfb-run command and comparing it with the three failing entries in ecosystem.config.js. Check how PM2 interprets script, interpreter, and args; done means establishing a supported configuration or documenting that configuration's limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.