Skip to content

Commit 76b672c

Browse files
committed
support swoole-cli
1 parent 44850f8 commit 76b672c

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/commands/ServerStopCommand.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,17 @@ public function handle()
5656
}elseif ($option_port){
5757
// kill process by port, cannot be used in wsl
5858
$servers = config('server.servers');
59-
foreach ($servers as $server){
60-
$port = $server['port'];
61-
$result = System::exec("lsof -i:".$port."|awk '{if (NR>1){print $2}}'"); // |xargs kill -9
62-
$pids = trim($result['output']);
63-
if(empty($pids)){
64-
stdLog()->warning('server not found');
65-
return;
66-
}
67-
$pids = explode(PHP_EOL, $pids);
68-
$pids = implode(' ', $pids);
69-
System::exec("kill -9 $pids");
70-
stdLog()->info("force stop server success by port `$port`");
59+
$port = $servers[0]['port'];
60+
$result = System::exec("lsof -i:".$port."|awk '{if (NR>1){print $2}}'"); // |xargs kill -9
61+
$pids = trim($result['output']);
62+
if(empty($pids)){
63+
stdLog()->warning('server not found');
64+
return;
7165
}
66+
$pids = explode(PHP_EOL, $pids);
67+
$pids = implode(' ', $pids);
68+
System::exec("kill -9 $pids");
69+
stdLog()->info("force stop server success by port `$port`");
7270
} else{
7371
// default kill process by hyperf.pid
7472
$master_pid = getMasterPid();

0 commit comments

Comments
 (0)