Don't loop over the rooms when we kill all anyway

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-09-22 14:46:26 +02:00
Родитель ce87e93999
Коммит c01ff3fa24
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -654,8 +654,9 @@ class MatterbridgeManager {
/**
* kill the mattermost processes (owned by web server unix user) that do not match with any room
* @param bool $killAll
*/
public function killZombieBridges(): void {
public function killZombieBridges(bool $killAll = false): void {
// get list of running matterbridge processes
$cmd = 'ps -ux | grep "commands/matterbridge" | grep -v grep | awk \'{print $2}\'';
exec($cmd, $output, $ret);
@ -669,6 +670,13 @@ class MatterbridgeManager {
return;
}
if ($killAll) {
foreach ($runningPidList as $runningPid) {
$this->killPid($runningPid);
}
return;
}
// get list of what should be running
$expectedPidList = [];
$this->manager->forAllRooms(function ($room) use (&$expectedPidList) {
@ -734,7 +742,7 @@ class MatterbridgeManager {
});
// finally kill all potential zombie matterbridge processes
$this->killZombieBridges();
$this->killZombieBridges(true);
return true;
}