pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

PM2 always restart

Open justquanyin opened this issue 10 years ago • 11 comments

System detail

pm2 verison 2.0.12 node version 4.5.0 OS

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:    14.04
Codename:   trusty
CPU :  2
MEM: 2G

pm2 ls

┌───────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────┬────────────┬──────────┐
│ App name  │ id │ mode    │ pid   │ status │ restart │ uptime │ cpu │ mem        │ watching │
├───────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────┼────────────┼──────────┤
│ qtp       │ 1  │ cluster │ 5469  │ online │ 103     │ 19m    │ 0%  │ 129.3 MB   │ disabled │
│ qtp       │ 2  │ cluster │ 5463  │ online │ 102     │ 19m    │ 0%  │ 126.6 MB   │ disabled │
│ qtpayment │ 3  │ fork    │ 19181 │ online │ 2       │ 25h    │ 0%  │ 70.6 MB    │ disabled │
└───────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────┴────────────┴──────────┘
 Module activated
┌───────────────┬─────────┬────────────┬────────┬─────────┬─────┬─────────────┐
│ Module        │ version │ target PID │ status │ restart │ cpu │ memory      │
├───────────────┼─────────┼────────────┼────────┼─────────┼─────┼─────────────┤
│ pm2-logrotate │ 2.0.0   │ 14626      │ online │ 1       │ 0%  │ 52.492 MB   │
└───────────────┴─────────┴────────────┴────────┴─────────┴─────┴─────────────┘
 Use `pm2 show <id|name>` to get more details about an app

pm2 log output

run command : tail --lines 50 ~/.pm2/pm2.log

2016-09-28 12:46:13: App name:qtp id:2 disconnected
2016-09-28 12:46:13: App [qtp] with id [2] and pid [9838], exited with code [0] via signal [SIGINT]
2016-09-28 12:46:13: Starting execution sequence in -cluster mode- for app name:qtp id:2
2016-09-28 12:46:13: App name:qtp id:2 online
2016-09-28 13:00:02: App name:qtp id:1 disconnected
2016-09-28 13:00:02: App [qtp] with id [1] and pid [9817], exited with code [0] via signal [SIGINT]
2016-09-28 13:00:02: Starting execution sequence in -cluster mode- for app name:qtp id:1
2016-09-28 13:00:02: App name:qtp id:1 online
2016-09-28 13:00:03: App name:qtp id:2 disconnected
2016-09-28 13:00:03: App [qtp] with id [2] and pid [16331], exited with code [0] via signal [SIGINT]
2016-09-28 13:00:03: Starting execution sequence in -cluster mode- for app name:qtp id:2
2016-09-28 13:00:03: App name:qtp id:2 online
2016-09-28 13:03:30: App name:qtp id:1 disconnected
2016-09-28 13:03:30: App [qtp] with id [1] and pid [17704], exited with code [0] via signal [SIGINT]
2016-09-28 13:03:30: Starting execution sequence in -cluster mode- for app name:qtp id:1
2016-09-28 13:03:30: App name:qtp id:1 online
2016-09-28 13:03:30: App name:qtp id:2 disconnected
2016-09-28 13:03:30: App [qtp] with id [2] and pid [17718], exited with code [0] via signal [SIGINT]
2016-09-28 13:03:30: Starting execution sequence in -cluster mode- for app name:qtp id:2
2016-09-28 13:03:30: App name:qtp id:2 online
2016-09-28 15:21:20: App name:qtp id:2 disconnected
2016-09-28 15:21:20: App [qtp] with id [2] and pid [18116], exited with code [0] via signal [SIGINT]
2016-09-28 15:21:20: Starting execution sequence in -cluster mode- for app name:qtp id:2
2016-09-28 15:21:20: App name:qtp id:1 disconnected
2016-09-28 15:21:20: App [qtp] with id [1] and pid [18092], exited with code [0] via signal [SIGINT]
2016-09-28 15:21:20: Starting execution sequence in -cluster mode- for app name:qtp id:1
2016-09-28 15:21:20: App name:qtp id:2 online
2016-09-28 15:21:20: App name:qtp id:1 online
2016-09-28 16:27:21: App name:qtp id:2 disconnected
2016-09-28 16:27:21: App [qtp] with id [2] and pid [31433], exited with code [0] via signal [SIGINT]
2016-09-28 16:27:21: Starting execution sequence in -cluster mode- for app name:qtp id:2
2016-09-28 16:27:21: App name:qtp id:1 disconnected
2016-09-28 16:27:21: App [qtp] with id [1] and pid [31439], exited with code [0] via signal [SIGINT]
2016-09-28 16:27:21: Starting execution sequence in -cluster mode- for app name:qtp id:1
2016-09-28 16:27:21: App name:qtp id:2 online
2016-09-28 16:27:21: App name:qtp id:1 online

please help me , thank you so much

justquanyin avatar Sep 28 '16 08:09 justquanyin

What's the problem exactly ? pm2 restart application as soon as they die, thats the normal behavior.

vmarchaud avatar Sep 28 '16 09:09 vmarchaud

why do always restart the application ? what is that reason ? Another 'qtpayment' only restart twice 。If that's normal behavior as restarted many times , I don't understand that pm2 designing style ..

justquanyin avatar Sep 28 '16 09:09 justquanyin

There are two reasons pm2 restart an application :

  • unhandledException exception is thrown but not catched by the application, in case the application crash.
  • unhandledRejection promise is rejected but not catched by the application.

You're problem might come from the fact that you aren't handling promise rejection, but be sure that your application doesnt crash because of an unhandledException (check in your application logs).

vmarchaud avatar Sep 28 '16 09:09 vmarchaud

ok , thank you so much . Expect perfect designing .

justquanyin avatar Sep 28 '16 09:09 justquanyin

@justquanyin Could you try using last build :

$ npm install pm2@next -g
$ pm2 update

vmarchaud avatar Sep 28 '16 11:09 vmarchaud

I do not think it's gonna fix your issue, as you were using PM2 2.0.12. Would it be possible to share with us some code so we can reproduce that issue?

Unitech avatar Sep 28 '16 15:09 Unitech

I'm having the same issue. Constant restarts with the absolute latest version. It started doing this when I used the following:

var P  = require('bluebird');
P.onPossiblyUnhandledRejection(function () {});

To clarify, I am using this because I am getting tons of warnings and my logs are growing huge. Meanwhile I am trying to figure out what is causing the warnings. Yet so far there is no change in my application (NODE 6.7.0) it's only pm2 that's not having a good time with this.

petergi avatar Sep 28 '16 18:09 petergi

@petergi Can you confirm that the version of pm2 that you are using (daemon and CLI) are 2.0.16 ?

vmarchaud avatar Sep 28 '16 19:09 vmarchaud

No they are 2.0.15. Update to 2.0.16 and it "seems" fine so far. I'll keep on I on it for the next few hours, but the behaviour is much better.
Thanks!

petergi avatar Sep 28 '16 22:09 petergi

@Unitech So sorry . I can't give us total code , but some code maybe not reproduce that issue . I need observe much logs and find reason to made crash or exception . After that , I will consult us . Thank you for your answer .

justquanyin avatar Sep 29 '16 02:09 justquanyin

[email protected] with fix published

$ npm install pm2@latest -g

Unitech avatar Sep 29 '16 09:09 Unitech