doc-pm2 icon indicating copy to clipboard operation
doc-pm2 copied to clipboard

Ecosystem File | Guide | PM2 Documentation

Open rmonnier9 opened this issue 7 years ago • 19 comments

https://pm2.io/doc/en/runtime/guide/ecosystem-file/

PM2 - Guide, References, Tutorials and Best Practices about PM2 and Node.js.

rmonnier9 avatar May 30 '18 14:05 rmonnier9

How to dump or list environment for current process? like pm2 about my_process

phan7om avatar Jun 18 '18 06:06 phan7om

@phan7om How to dump or list environment for current process? like pm2 about my_process

Hi! You can use pm2 prettylist to display all informations about the processes as json. You can save all processes added to the process list with pm2 dump and restore them with pm2 resurrect. I hope it will help.

rmonnier9 avatar Jun 18 '18 08:06 rmonnier9

hi, when i run pm2 ecosystem.config.js it´t toll me that app.js and web.js doen´t found, im new on that, can someone help me please?

alexferreras avatar Jun 18 '18 13:06 alexferreras

@AlexFerreras hi, when i run pm2 ecosystem.config.js it´t toll me that app.js and web.js doen´t found, im new on that, can someone help me please?

Hi! You probably need to edit the ecosystem file. Follow this article to know how. The most important is to set the script parameter with the path of your app entry point.

rmonnier9 avatar Jun 18 '18 15:06 rmonnier9

hi, once I start app with ecosystem.config.js, can I still change its setting ONLINE ( without restarting )? e.g. I want to disable log, but I don't like to restart?

jacinchan avatar Sep 14 '18 01:09 jacinchan

How to add custom environments like QA staging etc

Piusha avatar Oct 18 '18 04:10 Piusha

We could do something like

apps : [{ name: 'API', script: './bin/www',

instances: 1,
autorestart: true,
watch: true,
max_memory_restart: '1G',
env: {
  NODE_ENV: 'development'
},
env_production: {
  NODE_ENV: 'production'
},
env_qa:{
    NODE_ENV:'QA'
}

}],

and When you are calling

pm2 start ecosystem.config.js --env QA

Piusha avatar Oct 18 '18 08:10 Piusha

Can somebody confirm that the config file does not need to be named ecosystem.config.js please? I'm having issues where I can start any number of processes manually but starting from config files fails and I want to rule this out as an issue. (although currently I can even get an ecosystem.config.js to start my apps reliably)

suburbanworrier avatar Nov 14 '18 21:11 suburbanworrier

@suburbanworrier Can somebody confirm that the config file does not need to be named ecosystem.config.js please? I'm having issues where I can start any number of processes manually but starting from config files fails and I want to rule this out as an issue. (although currently I can even get an ecosystem.config.js to start my apps reliably)

you can name it whatever you want ex.: pm2 start whateveriwant.js

igordata avatar Nov 22 '18 12:11 igordata

Hi, anyone can tell me what the 'version' column in 'pm2 ps' is and how to specify it? I have deployed more than one version, I did tag the git repo with tag 1.0.2 - but nothing changed the version.

It'd be great to have the pm2 monit show the actual version of the app - even better if it would be automatically versioned :)

padcom avatar Feb 04 '19 16:02 padcom

OK - I figured it out :) The version field in monitoring is taken from package.json's version field :)

padcom avatar Feb 04 '19 16:02 padcom

can 'pm2 start ecosystem.config.js' specify a host like 'pm2 start ecosystem.config.js --host ... ' ? or shold I use deploy to specify a host?

luotiantian66 avatar Mar 07 '19 09:03 luotiantian66

when i switch env production it was error.

NhanHuynh2811 avatar May 12 '19 14:05 NhanHuynh2811

Is the ecosystem.config.js file mandatory? Or is it still possible to just specify stuff on the command line and not have that file?

Badestrand avatar May 14 '19 06:05 Badestrand

@igordata

@suburbanworrier Can somebody confirm that the config file does not need to be named ecosystem.config.js please? I'm having issues where I can start any number of processes manually but starting from config files fails and I want to rule this out as an issue. (although currently I can even get an ecosystem.config.js to start my apps reliably)

you can name it whatever you want ex.: pm2 start whateveriwant.js

That doesn't work for me, it only works if the file is exactly named ecosystem.config.js. E.g. naming the file pm2.js then pm2 will list the App name as "pm2" and restart all the time without output, indicating it tries to use it as an app and not as a configuration file. Please fix or adjust documentation.

Badestrand avatar May 14 '19 07:05 Badestrand

@Badestrand I did get pm2 to load ad-hoc named config files so there is definitely no dependency on ecosystem.config.js per se. Loading and updating configurations using config files didn't appear 100% reliable though - unfortunately nothing repeatable/reportable.

I recommend you keep trying :)

suburbanworrier avatar May 14 '19 07:05 suburbanworrier

@suburbanworrier @Badestrand I did get pm2 to load ad-hoc named config files so there is definitely no dependency on ecosystem.config.js per se. Loading and updating configurations using config files didn't appear 100% reliable though - unfortunately nothing repeatable/reportable.

I recommend you keep trying :)

Thank you for your reply. It loads pm2.config.js so maybe the ending just needs to be .config.js and .js itself is not enough? This really needs to be documented though!

Badestrand avatar May 14 '19 07:05 Badestrand

@Badestrand I can confirm that all of my working examples end .config.js so you may well have discovered the nub of the issue.

suburbanworrier avatar May 14 '19 08:05 suburbanworrier

Is it possible to use diff file name other than ecosystem.config.js

VimalKumarS avatar May 30 '19 01:05 VimalKumarS