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

Method reset

lib/API.js:344–384  ·  view source on GitHub ↗

* Reset process counters * * @method resetMetaProcess

(process_name, cb)

Source from the content-addressed store, hash-verified

342 * @method resetMetaProcess
343 */
344 reset (process_name, cb) {
345 var that = this;
346
347 function processIds(ids, cb) {
348 eachLimit(ids, conf.CONCURRENT_ACTIONS, function(id, next) {
349 that.Client.executeRemote('resetMetaProcessId', id, function(err, res) {
350 if (err) console.error(err);
351 Common.printOut(conf.PREFIX_MSG + 'Resetting meta for process id %d', id);
352 return next();
353 });
354 }, function(err) {
355 if (err) return cb(Common.retErr(err));
356 return cb ? cb(null, {success:true}) : that.speedList();
357 });
358 }
359
360 if (process_name == 'all') {
361 that.Client.getAllProcessId(function(err, ids) {
362 if (err) {
363 Common.printError(err);
364 return cb ? cb(Common.retErr(err)) : that.exitCli(conf.ERROR_EXIT);
365 }
366 return processIds(ids, cb);
367 });
368 }
369 else if (isNaN(process_name)) {
370 that.Client.getProcessIdByName(process_name, function(err, ids) {
371 if (err) {
372 Common.printError(err);
373 return cb ? cb(Common.retErr(err)) : that.exitCli(conf.ERROR_EXIT);
374 }
375 if (ids.length === 0) {
376 Common.printError('Unknown process name');
377 return cb ? cb(new Error('Unknown process name')) : that.exitCli(conf.ERROR_EXIT);
378 }
379 return processIds(ids, cb);
380 });
381 } else {
382 processIds([process_name], cb);
383 }
384 }
385
386 /**
387 * Update daemonized PM2 Daemon

Callers 3

Monit.jsFile · 0.45
CLI.jsFile · 0.45
misc_commands.jsFile · 0.45

Calls 4

cbFunction · 0.85
processIdsFunction · 0.85
exitCliMethod · 0.80
getProcessIdByNameMethod · 0.80

Tested by

no test coverage detected