* Reload an application * * @param {String} process_name Application Name or All * @param {Object} opts Options * @param {Function} cb Callback
(process_name, opts, cb)
| 436 | * @param {Function} cb Callback |
| 437 | */ |
| 438 | reload (process_name, opts, cb) { |
| 439 | var that = this; |
| 440 | |
| 441 | if (typeof(opts) == "function") { |
| 442 | cb = opts; |
| 443 | opts = {}; |
| 444 | } |
| 445 | |
| 446 | var delay = Common.lockReload(); |
| 447 | if (delay > 0 && opts.force != true) { |
| 448 | Common.printError(conf.PREFIX_MSG_ERR + 'Reload already in progress, please try again in ' + Math.floor((conf.RELOAD_LOCK_TIMEOUT - delay) / 1000) + ' seconds or use --force'); |
| 449 | return cb ? cb(new Error('Reload in progress')) : that.exitCli(conf.ERROR_EXIT); |
| 450 | } |
| 451 | |
| 452 | if (Common.isConfigFile(process_name)) |
| 453 | that._startJson(process_name, opts, 'reloadProcessId', function(err, apps) { |
| 454 | Common.unlockReload(); |
| 455 | if (err) |
| 456 | return cb ? cb(err) : that.exitCli(conf.ERROR_EXIT); |
| 457 | return cb ? cb(null, apps) : that.exitCli(conf.SUCCESS_EXIT); |
| 458 | }); |
| 459 | else { |
| 460 | if (opts && opts.env) { |
| 461 | var err = 'Using --env [env] without passing the ecosystem.config.js does not work' |
| 462 | Common.err(err); |
| 463 | Common.unlockReload(); |
| 464 | return cb ? cb(Common.retErr(err)) : that.exitCli(conf.ERROR_EXIT); |
| 465 | } |
| 466 | |
| 467 | if (opts && !opts.updateEnv) |
| 468 | Common.printOut(IMMUTABLE_MSG); |
| 469 | |
| 470 | that._operate('reloadProcessId', process_name, opts, function(err, apps) { |
| 471 | Common.unlockReload(); |
| 472 | |
| 473 | if (err) |
| 474 | return cb ? cb(err) : that.exitCli(conf.ERROR_EXIT); |
| 475 | return cb ? cb(null, apps) : that.exitCli(conf.SUCCESS_EXIT); |
| 476 | }); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | /** |
| 481 | * Restart process |
no test coverage detected