Use Swoole timers in Interval task

This commit is contained in:
Hemachandar
2026-01-29 11:28:17 +05:30
parent 7bf02811f2
commit 33e685f10c
2 changed files with 8 additions and 11 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ _APP_USAGE_AGGREGATION_INTERVAL=30
_APP_STATS_RESOURCES_INTERVAL=30
_APP_MAINTENANCE_RETENTION_USAGE_HOURLY=8640000
_APP_MAINTENANCE_RETENTION_SCHEDULES=86400
_APP_INTERVAL_DOMAIN_VERIFICATION=60
_APP_INTERVAL_DOMAIN_VERIFICATION=120
_APP_INTERVAL_CLEANUP_STALE_EXECUTIONS=300
_APP_USAGE_STATS=enabled
_APP_LOGGING_CONFIG=
+7 -10
View File
@@ -4,6 +4,7 @@ namespace Appwrite\Platform\Tasks;
use Appwrite\Event\Certificate;
use DateTime;
use Swoole\Timer;
use Utopia\CLI\Console;
use Utopia\Database\Database;
use Utopia\Database\DateTime as DatabaseDateTime;
@@ -34,19 +35,15 @@ class Interval extends Action
Console::title('Interval V1');
Console::success(APP_NAME . ' interval process v1 has started');
$intervalDomainVerification = (int) System::getEnv('_APP_INTERVAL_DOMAIN_VERIFICATION', '60'); // 1 minute
$intervalDomainVerification = (int) System::getEnv('_APP_INTERVAL_DOMAIN_VERIFICATION', '120'); // 2 minutes
$intervalCleanupStaleExecutions = (int) System::getEnv('_APP_INTERVAL_CLEANUP_STALE_EXECUTIONS', '300'); // 5 minutes
\go(function () use ($dbForPlatform, $queueForCertificates, $intervalDomainVerification) {
Console::loop(function () use ($dbForPlatform, $queueForCertificates) {
$this->verifyDomain($dbForPlatform, $queueForCertificates);
}, $intervalDomainVerification);
Timer::tick($intervalDomainVerification * 1000, function () use ($dbForPlatform, $queueForCertificates) {
$this->verifyDomain($dbForPlatform, $queueForCertificates);
});
\go(function () use ($dbForPlatform, $getProjectDB, $intervalCleanupStaleExecutions) {
Console::loop(function () use ($dbForPlatform, $getProjectDB) {
$this->cleanupStaleExecutions($dbForPlatform, $getProjectDB);
}, $intervalCleanupStaleExecutions);
Timer::tick($intervalCleanupStaleExecutions * 1000, function () use ($dbForPlatform, $getProjectDB) {
$this->cleanupStaleExecutions($dbForPlatform, $getProjectDB);
});
}
@@ -60,7 +57,7 @@ class Interval extends Action
Query::equal('status', [RULE_STATUS_CREATED]), // Created but not verified yet
Query::orderAsc('$updatedAt'), // Pick the ones waiting for another attempt for longest
Query::equal('region', [System::getEnv('_APP_REGION', 'default')]), // Only current region
Query::limit(30), // Reasonable pagination limit, processable within a minute
Query::limit(100), // Reasonable pagination limit
]);
if (\count($rules) === 0) {