PM2 ecosystem configs to run a service before running the node process
Open
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?
- First install
xvdfin your ubuntu 20.04 machine by running -sudo apt-get install xvfb - Then run any node program
xvfb-run -s "-ac -screen 0 1280x720x24" node app.js. It will work without any issue. - Then try any of these configurations as
ecosystem.config.jsbut 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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