Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.62k stars 2.63k forks source link

amqp gracefulRload Assertion #1637

Closed JunejaTung closed 8 years ago

JunejaTung commented 9 years ago

a simple webserver with amqp connection.

1. webserver(wtest) app run in cluster mode as:

[root@VirtualServer1 TEST]# pm2 start wtest.js -i 0
[PM2] Starting wtest.js in cluster_mode (0 instance) [PM2] Done. ┌────────────────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐ │ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │ ├────────────────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤ │ pm2-http-interface │ 0 │ fork │ 27265 │ online │ 0 │ 8h │ 23.863 MB │ disabled │ │ wtest │ 32 │ cluster │ 31296 │ online │ 0 │ 0s │ 15.141 MB │ disabled │ │ wtest │ 33 │ cluster │ 31299 │ online │ 0 │ 0s │ 12.090 MB │ disabled │ └────────────────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘ Use pm2 show <id|name> to get more details about an app [root@VirtualServer1 TEST]#

  1. another terminator Simulate concurrent web requests: [root@21Server expserver]# ab -n 5000 -c 100 http://192.168.110.30:8800/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.110.30 (be patient) Completed 500 requests Completed 1000 requests Completed 1500 requests Completed 2000 requests Completed 2500 requests Completed 3000 requests ...

3. then gracefulReload wtest app some AssertionError happen :

[root@VirtualServer1 TEST]# pm2 gracefulReload wtest all [PM2] Reloading process by name wtest [PM2] Process wtest succesfully reloaded [PM2] Process wtest succesfully reloaded [PM2] All processes reloaded ┌────────────────────┬────┬─────────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐ │ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │ ├────────────────────┼────┼─────────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤ │ pm2-http-interface │ 0 │ fork │ 27265 │ online │ 0 │ 8h │ 23.875 MB │ disabled │ │ wtest │ 32 │ cluster │ 31319 │ online │ 1 │ 23s │ 36.168 MB │ disabled │ │ wtest │ 33 │ cluster │ 31327 │ online │ 1 │ 12s │ 20.648 MB │ disabled │ └────────────────────┴────┴─────────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘ Use pm2 show <id|name> to get more details about an app [root@VirtualServer1 TEST]# pm2 logs wtest [PM2] Tailing last 20 lines for [wtest] process

wtest-32 (err): AssertionError: null == true wtest-32 (err): at process.target._send (child_process.js:420:5) wtest-32 (err): at process. (child_process.js:396:12) wtest-32 (err): at process.emit (events.js:129:20) wtest-32 (err): at handleMessage (child_process.js:324:10) wtest-32 (err): at Pipe.channel.onread (child_process.js:350:11)

wtest-32 (out): Reply id: 1605 wtest-32 (out): Request id: 1607 wtest-32 (out): Reply id: 1606 wtest-32 (out): Request id: 1608

4. callback for 'shutdown':

process.on('message', function (msg) { if (msg == 'shutdown') { server.close(); prodMQ.disconnect(); // close amqp connection console.log("Graceful close server."); setTimeout(function () { process.exit(0); }, 10000); } });

5. when i note prodMQ.disconnect();, then gracefulReload is OK.

why I disconnect the MQ connection hit the question in 3.

PM2 version is 0.14.7 Node.js version is 0.12.6

Best regards!

Unitech commented 9 years ago

Node.js version?

JunejaTung commented 9 years ago

[root@VirtualServer1 TEST]# node -v v0.12.6

best regards

Unitech commented 8 years ago

Fixed a long time ago

Make sure you check the new graceful stop system: http://pm2.keymetrics.io/docs/usage/signals-clean-restart/

$ npm install pm2@next -g
$ pm2 update
Unitech commented 8 years ago

Patch available on pm2@2.1.4 (main):

$ npm install pm2 -g
$ pm2 update