mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-11-07 19:03:36 +01:00
- The viewer APIs (player_api, enigma2, xplugin, epg, playlist) answer 404 on every load balancer: their controllers need Domain/User, which the LB build strips as privileged, so in mode 0 or 1 the routed request ended in a fatal error (UserRepository not found). viewer_api.conf is 0 on every node and in the archive; clients use MAIN's address (D16). - Debug mode keeps production's status (404, or the given code) when an error ends the request: a player read the 200 debug page as its playlist and stalled instead of reconnecting. - The root cron and cluster:root reload nginx once per pass. One save of a server's ports queued its HTTP, HTTPS and RTMP ports, each reloading nginx at once: reloads in the same second, and nginx aborted a worker (signal 6, nine times in MAIN's error.log, always right after a reload). - console.php status no longer prints a chmod error while PHP-FPM is stopped mid-update.
63 lines
2.2 KiB
PHP
63 lines
2.2 KiB
PHP
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use XcVm\Cli\CronJobs\RootSignalsCronJob;
|
|
|
|
/**
|
|
* nginx reloads once per root pass, whatever its actions ask. One save of a
|
|
* server's ports queues its HTTP, HTTPS and RTMP ports, and each reloaded
|
|
* nginx at once: two reloads in the same second, and nginx aborted a worker
|
|
* (signal 6 in MAIN's error.log). Every action now asks, and the pass (the
|
|
* root cron's minute, cluster:root's drain) reloads once at its end.
|
|
*/
|
|
final class RootNginxReloadTest extends TestCase {
|
|
/** @var list<list<string>> */
|
|
private array $rRan = [];
|
|
|
|
protected function setUp(): void {
|
|
RootSignalsCronJob::useRunner(function (array $rArgv): array {
|
|
$this->rRan[] = $rArgv;
|
|
return [0, ''];
|
|
});
|
|
RootSignalsCronJob::reloadAsked(); // nothing left from another test
|
|
$this->rRan = [];
|
|
}
|
|
|
|
protected function tearDown(): void {
|
|
RootSignalsCronJob::useRunner(null);
|
|
}
|
|
|
|
private function db(): object {
|
|
return new class {
|
|
public function query(string $rSql, mixed ...$rParams): bool {
|
|
return true;
|
|
}
|
|
};
|
|
}
|
|
|
|
public function testActionsAskAndThePassReloadsOnce(): void {
|
|
$rJob = new RootSignalsCronJob();
|
|
ob_start();
|
|
$rJob->executeAction(['action' => 'reload_nginx'], [], $this->db());
|
|
$rJob->executeAction(['action' => 'reload_nginx'], [], $this->db());
|
|
ob_end_clean();
|
|
$this->assertSame([], $this->rRan, 'an action reloads nothing itself');
|
|
|
|
RootSignalsCronJob::reloadAsked();
|
|
$this->assertSame([
|
|
['sudo', BIN_PATH . 'nginx_rtmp/sbin/nginx_rtmp', '-s', 'reload'],
|
|
['sudo', BIN_PATH . 'nginx/sbin/nginx', '-s', 'reload'],
|
|
], $this->rRan);
|
|
|
|
RootSignalsCronJob::reloadAsked();
|
|
$this->assertCount(2, $this->rRan, 'nothing asked since: no reload');
|
|
}
|
|
|
|
public function testNoActionReloadsNginxByItself(): void {
|
|
$rSource = (string) file_get_contents(dirname(__DIR__, 2) . '/src/Cli/CronJobs/RootSignalsCronJob.php');
|
|
$this->assertDoesNotMatchRegularExpression('/-s reload/', $rSource, 'every reload goes through reloadAsked()');
|
|
$rRoot = (string) file_get_contents(dirname(__DIR__, 2) . '/src/Cli/Commands/ClusterRootCommand.php');
|
|
$this->assertMatchesRegularExpression('/self::drain\([^;]+;\s*RootSignalsCronJob::reloadAsked\(\);/', $rRoot, 'cluster:root reloads once per drain');
|
|
}
|
|
}
|