MCPcopy
hub / github.com/Unitech/pm2 / restart

Method restart

lib/API.js:487–518  ·  view source on GitHub ↗

* Restart process * * @param {String} cmd Application Name / Process id / JSON application file / 'all' * @param {Object} opts Extra options to be updated * @param {Function} cb Callback

(cmd, opts, cb)

Source from the content-addressed store, hash-verified

485 * @param {Function} cb Callback
486 */
487 restart (cmd, opts, cb) {
488 if (typeof(opts) == "function") {
489 cb = opts;
490 opts = {};
491 }
492 var that = this;
493
494 if (typeof(cmd) === 'number')
495 cmd = cmd.toString();
496
497 if (cmd == "-") {
498 // Restart from PIPED JSON
499 process.stdin.resume();
500 process.stdin.setEncoding('utf8');
501 process.stdin.on('data', function (param) {
502 process.stdin.pause();
503 that.actionFromJson('restartProcessId', param, opts, 'pipe', cb);
504 });
505 }
506 else if (Common.isConfigFile(cmd) || typeof(cmd) === 'object')
507 that._startJson(cmd, opts, 'restartProcessId', cb);
508 else {
509 if (opts && opts.env) {
510 var err = 'Using --env [env] without passing the ecosystem.config.js does not work'
511 Common.err(err);
512 return cb ? cb(Common.retErr(err)) : that.exitCli(conf.ERROR_EXIT);
513 }
514 if (opts && !opts.updateEnv)
515 Common.printOut(IMMUTABLE_MSG);
516 that._operate('restartProcessId', cmd, opts, cb);
517 }
518 }
519
520 /**
521 * Delete process

Callers 15

Configuration.jsFile · 0.45
CLI.jsFile · 0.45
cluster.mocha.jsFile · 0.45
programmatic.jsFile · 0.45
watcher.jsFile · 0.45
env_switching.jsFile · 0.45
id.mocha.jsFile · 0.45
namespace.mocha.jsFile · 0.45
lazy_api.mocha.jsFile · 0.45
graceful.mocha.jsFile · 0.45
api.mocha.jsFile · 0.45

Calls 10

cbFunction · 0.85
toStringMethod · 0.80
actionFromJsonMethod · 0.80
_startJsonMethod · 0.80
exitCliMethod · 0.80
_operateMethod · 0.80
resumeMethod · 0.65
setEncodingMethod · 0.65
onMethod · 0.65
pauseMethod · 0.65

Tested by

no test coverage detected