قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-22 15:07:44 +00:00

* Allow signal handling in console commands * Stop archiving after receiving SIGINT/SIGTERM * Add tests for basic core:archive signal handling * Abort symfony archiving requests for SIGTERM * Add tests for non-symfony core:archive climulti methods * Add tests for core:archive sigint fallback if sigterm is not fully supported * Add tests for signal handling during core:archive init * Add tests for signal handling during core:archive scheduled tasks * Stop scheduled tasks after receiving SIGINT/SIGTERM * Add tests for signal handling during scheduled-tasks:run * Wrap signal handling support behind feature flag * Update CHANGELOG.md --------- Co-authored-by: Marc Neudert <marc@innocraft.com>
84 خطوط
1.8 KiB
PHP
84 خطوط
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Piwik\Plugins\CoreAdminHome\tests\Fixtures;
|
|
|
|
use Closure;
|
|
use Piwik\Container\Container;
|
|
use Piwik\DI;
|
|
use Piwik\Plugins\CoreAdminHome\tests\Fixtures\RunScheduledTasksProcessSignal\StepControl;
|
|
use Piwik\Plugins\Monolog\Handler\EchoHandler;
|
|
use Piwik\Tests\Framework\Fixture;
|
|
|
|
/**
|
|
* Provides container configuration and helpers to run process signal tests.
|
|
*/
|
|
class RunScheduledTasksProcessSignal extends Fixture
|
|
{
|
|
public const ENV_TRIGGER = 'MATOMO_TEST_RUN_SCHEDULED_TASKS_PROCESS_SIGNAL';
|
|
|
|
/**
|
|
* @var int
|
|
*/
|
|
public $idSite = 1;
|
|
|
|
/**
|
|
* @var StepControl
|
|
*/
|
|
public $stepControl;
|
|
|
|
/**
|
|
* @var bool
|
|
*/
|
|
private $inTestEnv;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->inTestEnv = (bool) getenv(self::ENV_TRIGGER);
|
|
|
|
$this->stepControl = new StepControl();
|
|
}
|
|
|
|
public function setUp(): void
|
|
{
|
|
Fixture::createSuperUser();
|
|
|
|
if (!self::siteCreated($this->idSite)) {
|
|
self::createWebsite('2021-01-01');
|
|
}
|
|
}
|
|
|
|
public function tearDown(): void
|
|
{
|
|
// empty
|
|
}
|
|
|
|
public function provideContainerConfig(): array
|
|
{
|
|
if (!$this->inTestEnv) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
'ini.tests.enable_logging' => 1,
|
|
'log.handlers' => static function (Container $c) {
|
|
return [$c->get(EchoHandler::class)];
|
|
},
|
|
'observers.global' => DI::add([
|
|
[
|
|
'ScheduledTasks.execute',
|
|
DI::value(Closure::fromCallable([$this->stepControl, 'handleScheduledTasksExecute'])),
|
|
],
|
|
]),
|
|
];
|
|
}
|
|
}
|