pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

PM2 keep spamming terminals on start

Open NivGreenstein opened this issue 2 years ago • 4 comments

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.

NivGreenstein avatar Jul 25 '23 19:07 NivGreenstein

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.

ghost avatar Jul 25 '23 21:07 ghost

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.

JhordanEdyvald avatar Jul 03 '24 21:07 JhordanEdyvald

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

ghost avatar Jul 03 '24 21:07 ghost

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.

murilogoedert avatar Oct 04 '24 23:10 murilogoedert