#5623 -- Make Now Playing delay customizable.
This commit is contained in:
parent
b48cb5e49a
commit
2c0456a5a5
|
@ -8,6 +8,7 @@ use App\Console\Command\CommandAbstract;
|
||||||
use App\Doctrine\ReloadableEntityManagerInterface;
|
use App\Doctrine\ReloadableEntityManagerInterface;
|
||||||
use App\Entity\Repository\StationRepository;
|
use App\Entity\Repository\StationRepository;
|
||||||
use App\Entity\Station;
|
use App\Entity\Station;
|
||||||
|
use App\Environment;
|
||||||
use App\Sync\NowPlaying\Task\BuildQueueTask;
|
use App\Sync\NowPlaying\Task\BuildQueueTask;
|
||||||
use App\Sync\NowPlaying\Task\NowPlayingTask;
|
use App\Sync\NowPlaying\Task\NowPlayingTask;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
|
@ -32,6 +33,7 @@ final class NowPlayingCommand extends CommandAbstract
|
||||||
private readonly BuildQueueTask $buildQueueTask,
|
private readonly BuildQueueTask $buildQueueTask,
|
||||||
private readonly NowPlayingTask $nowPlayingTask,
|
private readonly NowPlayingTask $nowPlayingTask,
|
||||||
private readonly Logger $logger,
|
private readonly Logger $logger,
|
||||||
|
private readonly Environment $environment
|
||||||
) {
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
@ -74,7 +76,7 @@ final class NowPlayingCommand extends CommandAbstract
|
||||||
|
|
||||||
$this->logger->info('Starting Now Playing sync task.');
|
$this->logger->info('Starting Now Playing sync task.');
|
||||||
|
|
||||||
$this->loop($station, $timeout);
|
$this->loop($station, $timeout, $this->environment->getNowPlayingDelayTime());
|
||||||
|
|
||||||
$this->logger->info('Now Playing sync task complete.');
|
$this->logger->info('Now Playing sync task complete.');
|
||||||
$this->logger->popProcessor();
|
$this->logger->popProcessor();
|
||||||
|
@ -82,7 +84,7 @@ final class NowPlayingCommand extends CommandAbstract
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loop(Station $station, int $timeout): void
|
private function loop(Station $station, int $timeout, int $delay): void
|
||||||
{
|
{
|
||||||
$threshold = time() + $timeout;
|
$threshold = time() + $timeout;
|
||||||
|
|
||||||
|
@ -109,7 +111,7 @@ final class NowPlayingCommand extends CommandAbstract
|
||||||
|
|
||||||
$this->em->clear();
|
$this->em->clear();
|
||||||
gc_collect_cycles();
|
gc_collect_cycles();
|
||||||
usleep(5000000);
|
sleep($delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ final class Environment
|
||||||
|
|
||||||
public const SYNC_SHORT_EXECUTION_TIME = 'SYNC_SHORT_EXECUTION_TIME';
|
public const SYNC_SHORT_EXECUTION_TIME = 'SYNC_SHORT_EXECUTION_TIME';
|
||||||
public const SYNC_LONG_EXECUTION_TIME = 'SYNC_LONG_EXECUTION_TIME';
|
public const SYNC_LONG_EXECUTION_TIME = 'SYNC_LONG_EXECUTION_TIME';
|
||||||
|
public const NOW_PLAYING_DELAY_TIME = 'NOW_PLAYING_DELAY_TIME';
|
||||||
|
|
||||||
public const LOG_LEVEL = 'LOG_LEVEL';
|
public const LOG_LEVEL = 'LOG_LEVEL';
|
||||||
public const SHOW_DETAILED_ERRORS = 'SHOW_DETAILED_ERRORS';
|
public const SHOW_DETAILED_ERRORS = 'SHOW_DETAILED_ERRORS';
|
||||||
|
@ -82,6 +83,7 @@ final class Environment
|
||||||
|
|
||||||
self::SYNC_SHORT_EXECUTION_TIME => 600,
|
self::SYNC_SHORT_EXECUTION_TIME => 600,
|
||||||
self::SYNC_LONG_EXECUTION_TIME => 1800,
|
self::SYNC_LONG_EXECUTION_TIME => 1800,
|
||||||
|
self::NOW_PLAYING_DELAY_TIME => 5,
|
||||||
|
|
||||||
self::PROFILING_EXTENSION_ENABLED => 0,
|
self::PROFILING_EXTENSION_ENABLED => 0,
|
||||||
self::PROFILING_EXTENSION_ALWAYS_ON => 0,
|
self::PROFILING_EXTENSION_ALWAYS_ON => 0,
|
||||||
|
@ -247,12 +249,23 @@ final class Environment
|
||||||
|
|
||||||
public function getSyncShortExecutionTime(): int
|
public function getSyncShortExecutionTime(): int
|
||||||
{
|
{
|
||||||
return (int)($this->data[self::SYNC_SHORT_EXECUTION_TIME] ?? 600);
|
return (int)(
|
||||||
|
$this->data[self::SYNC_SHORT_EXECUTION_TIME] ?? $this->defaults[self::SYNC_SHORT_EXECUTION_TIME]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSyncLongExecutionTime(): int
|
public function getSyncLongExecutionTime(): int
|
||||||
{
|
{
|
||||||
return (int)($this->data[self::SYNC_LONG_EXECUTION_TIME] ?? 1800);
|
return (int)(
|
||||||
|
$this->data[self::SYNC_LONG_EXECUTION_TIME] ?? $this->defaults[self::SYNC_LONG_EXECUTION_TIME]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNowPlayingDelayTime(): int
|
||||||
|
{
|
||||||
|
return (int)(
|
||||||
|
$this->data[self::NOW_PLAYING_DELAY_TIME] ?? $this->defaults[self::NOW_PLAYING_DELAY_TIME]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -183,22 +183,27 @@ final class AzuraCastEnvFile extends AbstractEnvFile
|
||||||
'default' => '128M',
|
'default' => '128M',
|
||||||
],
|
],
|
||||||
'PHP_MAX_EXECUTION_TIME' => [
|
'PHP_MAX_EXECUTION_TIME' => [
|
||||||
'name' => __('PHP Script Maximum Execution Time'),
|
'name' => __('PHP Script Maximum Execution Time (Seconds)'),
|
||||||
'description' => __('(in seconds)'),
|
|
||||||
'default' => 30,
|
'default' => 30,
|
||||||
],
|
],
|
||||||
Environment::SYNC_SHORT_EXECUTION_TIME => [
|
Environment::SYNC_SHORT_EXECUTION_TIME => [
|
||||||
'name' => __('Short Sync Task Execution Time'),
|
'name' => __('Short Sync Task Execution Time (Seconds)'),
|
||||||
'description' => __(
|
'description' => __(
|
||||||
'The maximum execution time (and lock timeout) for the 15-second, 1-minute and 5-minute synchronization tasks.'
|
'The maximum execution time (and lock timeout) for the 15-second, 1-minute and 5-minute synchronization tasks.'
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
Environment::SYNC_LONG_EXECUTION_TIME => [
|
Environment::SYNC_LONG_EXECUTION_TIME => [
|
||||||
'name' => __('Long Sync Task Execution Time'),
|
'name' => __('Long Sync Task Execution Time (Seconds)'),
|
||||||
'description' => __(
|
'description' => __(
|
||||||
'The maximum execution time (and lock timeout) for the 1-hour synchronization task.',
|
'The maximum execution time (and lock timeout) for the 1-hour synchronization task.',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Environment::NOW_PLAYING_DELAY_TIME => [
|
||||||
|
'name' => __('Now Playing Delay Time (Seconds)'),
|
||||||
|
'description' => __(
|
||||||
|
'The delay between Now Playing checks for every station. Decrease for more frequent checks at the expense of performance; increase for less frequent checks but better performance (for large installations).'
|
||||||
|
),
|
||||||
|
],
|
||||||
'PHP_FPM_MAX_CHILDREN' => [
|
'PHP_FPM_MAX_CHILDREN' => [
|
||||||
'name' => __('Maximum PHP-FPM Worker Processes'),
|
'name' => __('Maximum PHP-FPM Worker Processes'),
|
||||||
'default' => 5,
|
'default' => 5,
|
||||||
|
|
Loading…
Reference in New Issue