upgrade to @pm2/io 2.4.x + add test to verify auto restart of throwing application

This commit is contained in:
Unitech 2018-10-01 12:07:29 +02:00
parent 5e6819fc0d
commit e960cfd808
4 changed files with 53 additions and 1 deletions

View File

@ -159,7 +159,7 @@
},
"dependencies": {
"@pm2/agent": "^0.5.11",
"@pm2/io": "~2.3.11",
"@pm2/io": "~2.4.2",
"@pm2/js-api": "^0.5.15",
"async": "^2.6.1",
"blessed": "^0.1.81",

View File

@ -0,0 +1,49 @@
const pm2 = require('../..');
const should = require('should');
const path = require('path')
describe('PM2 auto restart on uncaughtexception', function() {
var test_path = path.join(__dirname, 'fixtures', 'auto-restart')
after((done) => {
pm2.delete('all', () => { done() })
})
before((done) => {
pm2.uninstall('all', () => {
pm2.delete('all', () => { done() })
})
})
it('should start a failing app in fork mode', function(done) {
pm2.start({
script: path.join(test_path, 'throw.js'),
}, (err, apps) => {
setTimeout(function() {
pm2.list((err, list) => {
should(list[0].pm2_env.restart_time).aboveOrEqual(0)
pm2.delete('throw', () => {
done()
})
})
}, 200)
})
})
it('should start a failing app in cluster mode', function(done) {
pm2.start({
script: path.join(test_path, 'throw.js'),
instances: 4
}, (err, apps) => {
setTimeout(function() {
pm2.list((err, list) => {
should(list[0].pm2_env.restart_time).aboveOrEqual(0)
pm2.delete('throw', () => {
done()
})
})
}, 200)
})
})
})

View File

@ -0,0 +1 @@
throw new Error('err')

View File

@ -48,6 +48,8 @@ spec "API tests"
mocha --exit --opts ./mocha.opts ./reload-locker.mocha.js
spec "Reload locker tests"
mocha --exit --opts ./mocha.opts ./auto_restart.mocha.js
spec "Auto restart feature when uncaughtException"
mocha --exit --opts ./mocha.opts ./version.mocha.js
spec "Package json version retriever"
mocha --exit --opts ./mocha.opts ./exp_backoff_restart_delay.mocha.js