* Reset process counters * * @method resetMetaProcess
(process_name, cb)
| 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 |
no test coverage detected