Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.57k stars 2.62k forks source link

PM2 keep spamming terminals on start #5647

Open NivGreenstein opened 1 year ago

NivGreenstein commented 1 year ago

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.

punowo commented 1 year ago

Might be a duplicate of https://github.com/Unitech/pm2/issues/2182 Ping me if you find a resolution. I haven't been able to.

JhordanEdyvald commented 4 months ago

I'm having the same problem, please if you fix it let me know. I've been trying to search on Google by keyword and nothing. It's as if no one exists with this problem.

punowo commented 4 months ago

@JhordanEdyvald Have you tried https://github.com/Unitech/pm2/issues/2182#issuecomment-2057721125 ?

murilogoedert commented 1 month ago

I'm having this issue, tested it in various PM2 versions, and the solutions from #2182 don't work anymore.

Last year, I was planning to build a command-line tool for my teammates and me to easily set up the development environment (microservices) and tried to use PM2 as the underlying tool via the JS API, but the popping windows made me give up.

I ended up doing everything manually with a UI terminal using Xterminal and child_process with execa, passing windowsHide: false in the child process configuration (I don't know why, but this worked perfectly).

 execa(command, args, {
     cwd: service.directory
     windowsHide: false,
});

Today, I tried again, hoping the problem had been solved, but it still happens. Both the JS API and pm2 start with ecosystem.config.js keep popping these annoying windows.