Remove usage of pkill (fix #286)
parent
f7bf45dc86
commit
6a0a3a370e
|
@ -234,7 +234,7 @@ class VideoController extends ApiBase
|
|||
$env .= "FFMPEG='{$ffmpegPath}' FFPROBE='{$ffprobePath}' GOVOD_TEMPDIR='{$tmpPath}/go-vod' ";
|
||||
|
||||
// Check if already running
|
||||
exec("pkill {$transcoder}");
|
||||
\OCA\Memories\Util::pkill($transcoder);
|
||||
shell_exec("{$env} nohup {$transcoder} > {$tmpPath}/go-vod.log 2>&1 & > /dev/null");
|
||||
|
||||
// wait for 1s and try again
|
||||
|
|
|
@ -25,7 +25,7 @@ class Repair implements IRepairStep
|
|||
public function run(IOutput $output): void
|
||||
{
|
||||
// kill any instances of go-transcode and go-vod
|
||||
shell_exec('pkill go-transcode');
|
||||
shell_exec('pkill go-vod');
|
||||
\OCA\Memories\Util::pkill('go-transcode');
|
||||
\OCA\Memories\Util::pkill('go-vod');
|
||||
}
|
||||
}
|
||||
|
|
16
lib/Util.php
16
lib/Util.php
|
@ -141,4 +141,20 @@ class Util
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill all instances of a process by name.
|
||||
* Similar to pkill, which may not be available on all systems.
|
||||
*/
|
||||
public static function pkill(string $name): void
|
||||
{
|
||||
// get pids using ps as array
|
||||
$pids = shell_exec("ps -ef | grep $name | grep -v grep | awk '{print $2}'");
|
||||
$pids = array_filter(explode("\n", $pids));
|
||||
|
||||
// kill all pids
|
||||
foreach ($pids as $pid) {
|
||||
posix_kill((int) $pid, SIGKILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue