* Update daemonized PM2 Daemon * * @param {Function} cb callback when pm2 has been upgraded
(cb)
| 389 | * @param {Function} cb callback when pm2 has been upgraded |
| 390 | */ |
| 391 | update (cb) { |
| 392 | var that = this; |
| 393 | |
| 394 | Common.printOut('Be sure to have the latest version by doing `npm install pm2@latest -g` before doing this procedure.'); |
| 395 | |
| 396 | // Dump PM2 processes |
| 397 | that.Client.executeRemote('notifyKillPM2', {}, function() {}); |
| 398 | |
| 399 | that.getVersion(function(err, new_version) { |
| 400 | // If not linked to PM2 plus, and update PM2 to latest, display motd.update |
| 401 | if (!that.gl_is_km_linked && !err && (pkg.version != new_version)) { |
| 402 | var dt = fs.readFileSync(path.join(__dirname, that._conf.PM2_UPDATE)); |
| 403 | console.log(dt.toString()); |
| 404 | } |
| 405 | |
| 406 | that.dump(function(err) { |
| 407 | that.killDaemon(function() { |
| 408 | that.Client.launchDaemon({interactor:false}, function(err, child) { |
| 409 | that.Client.launchRPC(function() { |
| 410 | that.resurrect(function() { |
| 411 | Common.printOut(chalk.blue.bold('>>>>>>>>>> PM2 updated')); |
| 412 | that.launchAll(that, function() { |
| 413 | KMDaemon.launchAndInteract(that._conf, { |
| 414 | pm2_version: pkg.version |
| 415 | }, function(err, data, interactor_proc) { |
| 416 | }) |
| 417 | setTimeout(() => { |
| 418 | return cb ? cb(null, {success:true}) : that.speedList(); |
| 419 | }, 250) |
| 420 | }); |
| 421 | }); |
| 422 | }); |
| 423 | }); |
| 424 | }); |
| 425 | }); |
| 426 | }); |
| 427 | |
| 428 | return false; |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Reload an application |
nothing calls this directly
no test coverage detected