Skip to content

Commit 5e27069

Browse files
committed
make pid file compatible with older versions
1 parent 924363b commit 5e27069

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Commands/HttpServerCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ protected function showInfos()
212212
$isWebsocket = Arr::get($this->config, 'websocket.enabled');
213213
$hasTaskWorker = $isWebsocket || Arr::get($this->config, 'queue.default') === 'swoole';
214214
$logFile = Arr::get($this->config, 'server.options.log_file');
215-
$pidManager = $this->laravel->make(PidManager::class);
216-
[$masterPid, $managerPid] = $pidManager->read();
215+
$pids = $this->laravel->make(PidManager::class)->read();
216+
$masterPid = $pids['masterPid'] ?? null;
217+
$managerPid = $pids['managerPid'] ?? null;
217218

218219
$table = [
219220
['PHP Version', 'Version' => phpversion()],

src/Server/PidManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ public function read(): array
5858
$pids = explode(',', $content);
5959
}
6060

61-
return $pids;
61+
return [
62+
'masterPid' => $pids[0] ?? null,
63+
'managerPid' => $pids[1] ?? null
64+
];
6265
}
6366

6467
/**

tests/Server/PidManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testRead()
6767
});
6868

6969
$this->assertEquals(
70-
['1', '2'],
70+
['masterPid' => '1', 'managerPid' => '2'],
7171
$pidManager->read()
7272
);
7373
}

0 commit comments

Comments
 (0)