From 8488f67d63d16fccfbc5c13ff5b4eb9eeae27339 Mon Sep 17 00:00:00 2001 From: Muhammad Farhan Tahir <39334336+MuhammadFarhantahir@users.noreply.github.com> Date: Sun, 19 Jul 2026 00:22:43 +0500 Subject: [PATCH] fix(cli): reload multiple process names pm2 reload a b silently dropped every name after the first: the reload command was declared '' while stop and restart are variadic. Mirror restart's forEachLimit loop and cover multi-name reload in the multiparam e2e test. Co-Authored-By: Claude Fable 5 --- lib/binaries/CLI.js | 16 +++++++++++++--- test/e2e/cli/multiparam.sh | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/binaries/CLI.js b/lib/binaries/CLI.js index 209cb0ba8e..f8e9be753f 100644 --- a/lib/binaries/CLI.js +++ b/lib/binaries/CLI.js @@ -416,10 +416,20 @@ commander.command('profile:cpu [time]') // // Reload process(es) // -commander.command('reload ') +commander.command('reload ') .description('reload processes (note that its for app using HTTP/HTTPS)') - .action(function(pm2_id) { - pm2.reload(pm2_id, commander); + .action(function(param) { + // Commander.js patch + param = patchCommanderArg(param); + let acc = [] + forEachLimit(param, 1, function(script, next) { + pm2.reload(script, commander, (err, apps) => { + acc = acc.concat(apps) + next(err) + }); + }, function(err) { + pm2.speedList(err ? 1 : 0, acc); + }); }); commander.command('id ') diff --git a/test/e2e/cli/multiparam.sh b/test/e2e/cli/multiparam.sh index f26bbfba79..fc48f10cf8 100644 --- a/test/e2e/cli/multiparam.sh +++ b/test/e2e/cli/multiparam.sh @@ -14,6 +14,10 @@ $pm2 restart child echo server should 'should app be online' 'online' 3 should 'should all script been restarted one time' 'restart_time: 1' 3 +## Reload +$pm2 reload child echo server +should 'should all script been restarted two times' 'restart_time: 2' 3 + ## Stop $pm2 stop child echo server should 'should app be stopped' 'stopped' 3