From 5c02b82473cfc833bf1e0acdfe41610a05c37608 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Mon, 7 Sep 2020 11:13:39 +0200 Subject: [PATCH] check if Matterbridge processes are running correctly and kill the zombie ones every 15 min Signed-off-by: Julien Veyssier --- appinfo/info.xml | 1 + lib/BackgroundJob/CheckMatterbridges.php | 57 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 lib/BackgroundJob/CheckMatterbridges.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 2e6465533f8..dabf2d07481 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -56,6 +56,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m OCA\Talk\BackgroundJob\ResetAssignedSignalingServer OCA\Talk\BackgroundJob\CheckReferenceIdColumn OCA\Talk\BackgroundJob\CheckHostedSignalingServer + OCA\Talk\BackgroundJob\CheckMatterbridges diff --git a/lib/BackgroundJob/CheckMatterbridges.php b/lib/BackgroundJob/CheckMatterbridges.php new file mode 100644 index 00000000000..fbf6fe997a1 --- /dev/null +++ b/lib/BackgroundJob/CheckMatterbridges.php @@ -0,0 +1,57 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Talk\BackgroundJob; + +use OC\BackgroundJob\TimedJob; +use OCA\Talk\MatterbridgeManager; +use Psr\Log\LoggerInterface; + +/** + * Class CheckMatterbridges + * + * @package OCA\Talk\BackgroundJob + */ +class CheckMatterbridges extends TimedJob { + + /** @var MatterbridgeManager */ + protected $bridgeManager; + + /** @var LoggerInterface */ + protected $logger; + + public function __construct(MatterbridgeManager $bridgeManager, + LoggerInterface $logger) { + // Every 15 minutes + $this->setInterval(60 * 15); + + $this->bridgeManager = $bridgeManager; + $this->logger = $logger; + } + + protected function run($argument): void { + $this->bridgeManager->checkAllBridges(); + $this->bridgeManager->killZombieBridges(); + $this->logger->info('Checked if Matterbridge instances are running correctly.'); + } +}