Unitech / Unitech/pm2

PM2 keep spamming terminals on start

Open
#5,647 4 comments 0 reactions 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

I have created pm2 Ecosystem File that looks like this:

const os = require('os');
const fs = require('fs');
const path = require('path');

const services = [ 
        {name: 'gatewayService', port: 3000}, 
        {name: 'microserviceA', port: 3001},
        {name: 'microserviceB', port: 3002}
];

const backend = services.map(service => ({
                script: 'src/index.ts',
                node_args: ' -r ts-node/register',
                interpreter: 'node'm
                max_restarts: 10,
                detached: true,
                name: service.name,
                watch: ['src'],
                cwd: `../${service.name}`,
                env :{
                        port: service.port, 
                        ...otherEnvs
                }
        }));

module.exports = {
  apps: backend
};

In the CMD I run pm2 run ./ecosystemFile.js.

For some reason that I can't figure out way, it keeps spamming on start with terminals (i figured out it's the node process).
I don't know why but even the max_restart policy is being ignored.

Searched for few days but nothing seems to work.

Specs: Windows 11, node 16.16.0, pm2-latest - running on fork mode.

Thanks.

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 with ecosystemFile.js and the src/index.ts entry point, then reproduce pm2 run ./ecosystemFile.js on Windows 11 using the reported configuration. Check why startup repeatedly opens node processes or terminals and whether the max_restarts setting is being applied. Done means the repeated startup behavior and restart-limit handling are explained and covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.