mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
upgrade to @pm2/io 2.4.x + add test to verify auto restart of throwing application
This commit is contained in:
parent
5e6819fc0d
commit
e960cfd808
@ -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",
|
||||
|
||||
49
test/programmatic/auto_restart.mocha.js
Normal file
49
test/programmatic/auto_restart.mocha.js
Normal 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)
|
||||
})
|
||||
})
|
||||
})
|
||||
1
test/programmatic/fixtures/auto-restart/throw.js
Normal file
1
test/programmatic/fixtures/auto-restart/throw.js
Normal file
@ -0,0 +1 @@
|
||||
throw new Error('err')
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user