Allow PM2 CLI to recognize custom ecosystem filenames like ecosystem.dev.js

Open
#6,021 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the pm2 start CLI handling described in the issue and reproduce it using ecosystem.dev.js with the supplied example. Trace how ecosystem.config.js is identified and how apps are loaded. Done means the custom filename is treated as an ecosystem configuration and both defined apps are spawned rather than the file being run as a script.

Written by the indexing model from the issue text.

Description

Description:
Currently PM2 only treats files named exactly ecosystem.config.js
as valid ecosystem configuration files. If I run pm2 start ecosystem.dev.js,
PM2 interprets it as a script instead of a config file and doesn't load all defined apps.

Use case:
I maintain multiple environment-specific config files (ecosystem.dev.js,
ecosystem.test.js, ecosystem.prod.js). I'd like to be able to start/select them via CLI
(e.g. pm2 start --config ecosystem.dev.js or with --config-file),
similar to how many tools allow a --config flag.

Expected behavior:

  • PM2 should recognize or allow specifying custom config filenames
  • Treat them same as ecosystem.config.js, i.e. load all apps

Fictive example: ecosystem.dev.js

const path = require('path');
module.exports = {
apps: [
{ name: 'app-dev', cwd: path.resolve(__dirname, '../../backend'), script: 'node server-dev.js' },
{ name: 'worker-dev', script: 'node worker-dev.js' }]};

Expected pm2 start ecosystem.dev.js to spawn both apps—not run the file itself.

pm2 --version
6.0.8

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

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.

More from Unitech/pm2

All issues in Unitech/pm2

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.