From cf1109e5fda3a2b449a588a4329d9e608311ae41 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 24 Feb 2023 09:12:23 -0800 Subject: [PATCH] video-setup: kill existing processes --- lib/Command/VideoSetup.php | 10 ++++++++++ lib/Util.php | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/lib/Command/VideoSetup.php b/lib/Command/VideoSetup.php index 6ca22115..777f1f1b 100644 --- a/lib/Command/VideoSetup.php +++ b/lib/Command/VideoSetup.php @@ -130,6 +130,8 @@ class VideoSetup extends Command $this->config->setSystemValue('memories.no_transcode', true); $output->writeln('Transcoding and HLS are now disabled'); + $this->killGoVod($output, $goVodPath); + return 0; } @@ -157,6 +159,8 @@ class VideoSetup extends Command $this->config->setSystemValue('memories.qsv', false); } + $this->killGoVod($output, $goVodPath); + return 0; } @@ -183,4 +187,10 @@ class VideoSetup extends Command return 0; } + + protected function killGoVod(OutputInterface $output, string $path): void + { + $output->writeln("\nKilling any existing go-vod processes"); + \OCA\Memories\Util::pkill($path); + } } diff --git a/lib/Util.php b/lib/Util.php index 8496a30f..7814a4b4 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -157,6 +157,11 @@ class Util */ public static function pkill(string $name): void { + // don't kill everything + if (empty($name)) { + return; + } + // get pids using ps as array $pids = shell_exec("ps -ef | grep {$name} | grep -v grep | awk '{print $2}'"); if (null === $pids || empty($pids)) {