I'm setting up pm2 metrics with my express app. We have everything set up through the command line running pm2 install
Is this possible within pm2 itself without having to run those pm2 commands as npm pre-scripts?
pm2 version => 2.7.2
nodejs version => 8.4.0
operating system => Windows 7
Thanks!
Nothing really wrong, just wondering if we could automate the install of pm2 modules through config.
Install a pm2 module with a module on one machine, install pm2 on another machine, obviously the module won't be there. :)
Kind of described what I'm looking to do up top.
Please run the following command (available on PM2 >= 2.6)
===============================================================================
--- PM2 REPORT (Thu Nov 09 2017 09:20:20 GMT-0500 (Eastern Standard Time)) ----
===============================================================================
--- Daemon -------------------------------------------------
pm2d version : 2.7.2
node version : 8.4.0
node path : undefined
argv : C:\Program Files\nodejs\node.exe,C:\Repositories\cprapi\node_modules\pm2\lib\Daemon.js
argv0 : node
user : undefined
uid : N/A
gid : N/A
uptime : 39min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 2.7.2
node version : 8.4.0
node path : undefined
argv : C:\Program Files\nodejs\node.exe,C:\Repositories\cprapi\node_modules\pm2\bin\pm2,report
argv0 : node
user : undefined
This feature would help speed up setting up modules like pm2-logrotate.
Thank you for creating this ticket.
Really nice feature~ Would say bye to something like pm2 set pm2-logrotate:xxxxx in scripts.
Hi @danscrima,
I'm ok to make a command like "pm2 install" which can install all modules found in a specific file.
But start command should stay as is. I mean, you will have to :
$ pm2 install
$ pm2 start my-app.js
Does that sound good for you ?
Sure that would be fine! It would behave just like npm install and npm start, which would be great. Thanks!
@danscrima
I create PR https://github.com/Unitech/pm2/pull/3458
It's still WIP but now pm2 can :
To install multiple modules you can use :
pm2 install
And it will check for ecosystem.json (like package.json for npm)
pm2 install my_ecosystem_file.json
I add it just in case people use a different file's name.
If something is missing just tell me ;)
PM2 2.10.1 has been release:
$ npm install pm2@latest -g
$ pm2 update
@wallet77 Thank you for the contribution.
Could you provide a basic example on how to setup the my_ecosystem_file.json file to do the following?
pm2 install pm2-logrotatepm2 set pm2-logrotate:xxxxxHi @nitrocode,
"pm2 install" can only do the first requirement.
It only install module and doesn't configure it. You still need to do it by yourself.
In ecosystem.json :
{
"apps": [{
"name": "my-app",
"script": "./index.js",
"cwd": "/home/www/project_root/current",
"error_file": "/home/www/project_root/logs/app.err.log",
"out_file": "../logs/app.out.log", #this is the same as the absolute error_file path
"exec_mode": "fork_mode",
"dependencies": ['pm2-logrotate']
}]
}
Thanks for the example! At the moment, with our setup, the changes you made will allow us to omit the module installation command but we still need to configure 5 or 6 different pm2 logrotate settings.
I think the original idea behind the ticket was to resolve both conditions so no additional commands need to be run in order to setup all of pm2. Perhaps we can create a new issue for the second condition.
I don't see this possibility in the official doc: https://pm2.keymetrics.io/docs/advanced/pm2-module-system/#default-values
Most helpful comment
Thanks for the example! At the moment, with our setup, the changes you made will allow us to omit the module installation command but we still need to configure 5 or 6 different pm2 logrotate settings.
I think the original idea behind the ticket was to resolve both conditions so no additional commands need to be run in order to setup all of
pm2. Perhaps we can create a new issue for the second condition.