mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
fix: keep wait_ready to his initial state on pm2 reload all #4069
This commit is contained in:
parent
f0c465db55
commit
bb1918971b
@ -1085,6 +1085,10 @@ class API {
|
||||
// Is KM linked?
|
||||
resolved_paths.km_link = that.gl_is_km_linked;
|
||||
|
||||
if (resolved_paths.wait_ready) {
|
||||
Common.warn(`App ${resolved_paths.name} has option 'wait_ready' set, waiting for app to be ready...`)
|
||||
}
|
||||
|
||||
that.Client.executeRemote('prepare', resolved_paths, function(err, data) {
|
||||
if (err) {
|
||||
Common.printError(conf.PREFIX_MSG_ERR + 'Process failed to launch %s', err.message ? err.message : err);
|
||||
|
||||
@ -465,6 +465,11 @@ Common.log = function(msg) {
|
||||
return console.log(`${cst.PREFIX_MSG}${msg}`);
|
||||
}
|
||||
|
||||
Common.warn = function(msg) {
|
||||
if (process.env.PM2_SILENT || process.env.PM2_PROGRAMMATIC === 'true') return false;
|
||||
return console.log(`${cst.PREFIX_MSG_WARNING}${msg}`);
|
||||
}
|
||||
|
||||
Common.logMod = function(msg) {
|
||||
if (process.env.PM2_SILENT || process.env.PM2_PROGRAMMATIC === 'true') return false;
|
||||
return console.log(`${cst.PREFIX_MSG_MOD}${msg}`);
|
||||
|
||||
@ -122,8 +122,6 @@ function hardReload(God, id, wait_msg, cb) {
|
||||
old_worker.pm2_env.pm_id = t_key;
|
||||
old_worker.pm_id = t_key;
|
||||
|
||||
new_env.wait_ready = false;
|
||||
|
||||
God.executeApp(new_env, function(err, new_worker) {
|
||||
if (err) return cb(err);
|
||||
|
||||
|
||||
2
test/fixtures/listen-timeout/wait-ready.js
vendored
2
test/fixtures/listen-timeout/wait-ready.js
vendored
@ -10,7 +10,7 @@ var server = http.createServer(function(req, res) {
|
||||
// 1# Notify application ready
|
||||
setTimeout(function() {
|
||||
process.send('ready');
|
||||
}, 2000);
|
||||
}, 1000);
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -19,8 +19,10 @@ describe('Wait ready / Graceful start / restart', function() {
|
||||
cwd : '../fixtures/listen-timeout/'
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
pm2.kill(done)
|
||||
before(function(done) {
|
||||
pm2.delete('all', function() {
|
||||
done()
|
||||
});
|
||||
});
|
||||
|
||||
describe('(FORK) Listen timeout feature', function() {
|
||||
@ -49,7 +51,7 @@ describe('Wait ready / Graceful start / restart', function() {
|
||||
should(apps[0].pm2_env.status).eql('online');
|
||||
done();
|
||||
})
|
||||
}, 3000);
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
it('should have listen timeout updated', function(done) {
|
||||
@ -61,7 +63,7 @@ describe('Wait ready / Graceful start / restart', function() {
|
||||
|
||||
it('should take listen timeout into account', function(done) {
|
||||
var called = false;
|
||||
var plan = new Plan(3, done);
|
||||
var plan = new Plan(4, done);
|
||||
|
||||
setTimeout(function() {
|
||||
should(called).be.false();
|
||||
@ -71,6 +73,11 @@ describe('Wait ready / Graceful start / restart', function() {
|
||||
setTimeout(function() {
|
||||
should(called).be.true();
|
||||
plan.ok(true);
|
||||
|
||||
pm2.list((err, apps) => {
|
||||
should(apps[0].pm2_env.wait_ready).eql(true)
|
||||
plan.ok(true)
|
||||
})
|
||||
}, 1500);
|
||||
|
||||
pm2.reload('all', function(err, data) {
|
||||
@ -123,15 +130,16 @@ describe('Wait ready / Graceful start / restart', function() {
|
||||
script : './wait-ready.js',
|
||||
listen_timeout : 1000,
|
||||
wait_ready : true,
|
||||
instances : 2,
|
||||
name : 'echo'
|
||||
instances : 1,
|
||||
exec_mode: 'cluster',
|
||||
name : 'http'
|
||||
});
|
||||
|
||||
setTimeout(function() {
|
||||
pm2.list(function(err, apps) {
|
||||
should(apps[0].pm2_env.status).eql('launching');
|
||||
});
|
||||
}, 800);
|
||||
}, 500);
|
||||
|
||||
setTimeout(function() {
|
||||
pm2.list(function(err, apps) {
|
||||
@ -140,6 +148,32 @@ describe('Wait ready / Graceful start / restart', function() {
|
||||
})
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
it('should take listen timeout into account', function(done) {
|
||||
var called = false;
|
||||
var plan = new Plan(4, done);
|
||||
|
||||
setTimeout(function() {
|
||||
should(called).be.false();
|
||||
plan.ok(true);
|
||||
}, 500);
|
||||
|
||||
setTimeout(function() {
|
||||
should(called).be.true();
|
||||
plan.ok(true);
|
||||
|
||||
pm2.list((err, apps) => {
|
||||
should(apps[0].pm2_env.wait_ready).eql(true)
|
||||
plan.ok(true)
|
||||
})
|
||||
}, 1500);
|
||||
|
||||
pm2.reload('all', function(err, data) {
|
||||
called = true;
|
||||
plan.ok(true);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user