saikatharryc / pm2-prometheus-exporter

:rabbit: :rabbit: pm2 prometheus exporter
146 stars 37 forks source link

when exec "pm2 kill",the pm2-metrics will not start automatically #60

Closed AlliotTech closed 3 years ago

AlliotTech commented 3 years ago

because of network problem, i have to use "git clone && npm install " and push the static files into my server ,and "pm2 install ." to run.

but when i use "pm2 kill " ,then "pm2 status " .the pm2-metrics will no start automatically.

if i run with "pm2 install pm2-metrics" , the pm2-metrics will start automatically after i run "pm2 kill && pm2 status"...

Can you tell me how I can make the previous mode start automatically

saikatharryc commented 3 years ago

@AlliotTech

I believe you have some customization in place? please confirm with me.

If I understood the issue correctly,

you usually run pm2-metrics by cloning from the git repo and not by pm2 install pm2-metrics

and when you usually do pm2 kill it just stops and does not spawn back? (when started from the git cloned repo) and even though you do pm2 kill it just spawns back, when you did pm2 install pm2-metrics to start the pm2-metrics

am I correct on the above?

AlliotTech commented 3 years ago

Thanks for your reply. yes~ you are right~ That is to say, I used pm2 install pm2-matrics to install online. After pm2 kill, it can spawn back automatically. but if I use:

    $ git clone https://github.com/saikatharryc/pm2-prometheus-exporter.git
    $ npm install
    $ pm2 start exporter.js --name pm2-metrics

like this way, After I execute pm2 kill to kill it, it won't restart properly.

saikatharryc commented 3 years ago

well, I see the problem, modules are designed to keep like that. although. did you try using pm2 restart all? or maybe pm2 reload all (if cluster mode) in this way, you don't have to kill the processes completely. and the service will respawn with another PID.

AlliotTech commented 3 years ago

due to my own node project is use pm2 kill to redeployment to avoid some other problems. so I can't use pm2 restart to restart all...

saikatharryc commented 3 years ago

would you mind sharing the configuration details for another service that you run, which spawns automatically even you do pm2 kill? I can then just figure out if I'm missing out something in the configuration, it's just the pm2 thingy.