rename task to Interval

This commit is contained in:
Hemachandar
2025-12-23 16:32:43 +05:30
parent cf90653deb
commit 47ea2893c3
8 changed files with 25 additions and 24 deletions
+2 -2
View File
@@ -101,8 +101,8 @@ _APP_USAGE_AGGREGATION_INTERVAL=30
_APP_STATS_RESOURCES_INTERVAL=30
_APP_MAINTENANCE_RETENTION_USAGE_HOURLY=8640000
_APP_MAINTENANCE_RETENTION_SCHEDULES=86400
_APP_MAINTENANCE_RULE_DOMAIN_VERIFICATION_INTERVAL=60
_APP_MAINTENANCE_RULE_CERTIFICATE_RENEWAL_INTERVAL=86400
_APP_INTERVAL_DOMAIN_VERIFICATION=60
_APP_INTERVAL_CERTIFICATE_RENEWAL=86400
_APP_USAGE_STATS=enabled
_APP_LOGGING_CONFIG=
_APP_LOGGING_CONFIG_REALTIME=
+1 -1
View File
@@ -57,8 +57,8 @@ RUN mkdir -p /storage/uploads && \
# Executables
RUN chmod +x /usr/local/bin/doctor && \
chmod +x /usr/local/bin/install && \
chmod +x /usr/local/bin/interval && \
chmod +x /usr/local/bin/maintenance && \
chmod +x /usr/local/bin/maintenance-rules && \
chmod +x /usr/local/bin/migrate && \
chmod +x /usr/local/bin/realtime && \
chmod +x /usr/local/bin/schedule-functions && \
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
php /usr/src/code/app/cli.php interval $@
-3
View File
@@ -1,3 +0,0 @@
#!/bin/sh
php /usr/src/code/app/cli.php maintenance-rules $@
+5 -5
View File
@@ -787,10 +787,10 @@ services:
- _APP_MAINTENANCE_START_TIME
- _APP_DATABASE_SHARED_TABLES
appwrite-task-maintenance-rules:
entrypoint: maintenance-rules
appwrite-task-interval:
entrypoint: interval
<<: *x-logging
container_name: appwrite-task-maintenance-rules
container_name: appwrite-task-interval
image: appwrite-dev
networks:
- appwrite
@@ -822,8 +822,8 @@ services:
- _APP_DB_USER
- _APP_DB_PASS
- _APP_DATABASE_SHARED_TABLES
- _APP_MAINTENANCE_RULE_DOMAIN_VERIFICATION_INTERVAL
- _APP_MAINTENANCE_RULE_CERTIFICATE_RENEWAL_INTERVAL
- _APP_INTERVAL_DOMAIN_VERIFICATION
- _APP_INTERVAL_CERTIFICATE_RENEWAL
appwrite-task-stats-resources:
container_name: appwrite-task-stats-resources
+2 -2
View File
@@ -5,7 +5,7 @@ namespace Appwrite\Platform\Services;
use Appwrite\Platform\Tasks\Doctor;
use Appwrite\Platform\Tasks\Install;
use Appwrite\Platform\Tasks\Maintenance;
use Appwrite\Platform\Tasks\MaintenanceRules;
use Appwrite\Platform\Tasks\Interval;
use Appwrite\Platform\Tasks\Migrate;
use Appwrite\Platform\Tasks\QueueRetry;
use Appwrite\Platform\Tasks\ScheduleExecutions;
@@ -29,8 +29,8 @@ class Tasks extends Service
$this
->addAction(Doctor::getName(), new Doctor())
->addAction(Install::getName(), new Install())
->addAction(Interval::getName(), new Interval())
->addAction(Maintenance::getName(), new Maintenance())
->addAction(MaintenanceRules::getName(), new MaintenanceRules())
->addAction(Migrate::getName(), new Migrate())
->addAction(QueueRetry::getName(), new QueueRetry())
->addAction(SDKs::getName(), new SDKs())
@@ -12,17 +12,17 @@ use Utopia\Database\Query;
use Utopia\Platform\Action;
use Utopia\System\System;
class MaintenanceRules extends Action
class Interval extends Action
{
public static function getName(): string
{
return 'maintenance-rules';
return 'interval';
}
public function __construct()
{
$this
->desc('Schedules periodic tasks for rule verification and certificate renewal')
->desc('Schedules tasks on regular intervals by publishing them to our queues')
->inject('dbForPlatform')
->inject('queueForCertificates')
->callback($this->action(...));
@@ -30,22 +30,22 @@ class MaintenanceRules extends Action
public function action(Database $dbForPlatform, Certificate $queueForCertificates): void
{
Console::title('Rule maintenance V1');
Console::success(APP_NAME . ' rule maintenance process v1 has started');
Console::title('Interval V1');
Console::success(APP_NAME . ' interval process v1 has started');
$intervalRuleDomainVerification = (int) System::getEnv('_APP_MAINTENANCE_RULE_DOMAIN_VERIFICATION_INTERVAL', '60'); // 1 minute
$intervalRuleCertificateRenewal = (int) System::getEnv('_APP_MAINTENANCE_RULE_CERTIFICATE_RENEWAL_INTERVAL', '86400'); // 1 day
$intervalDomainVerification = (int) System::getEnv('_APP_INTERVAL_DOMAIN_VERIFICATION', '60'); // 1 minute
$intervalCertificateRenewal = (int) System::getEnv('_APP_INTERVAL_CERTIFICATE_RENEWAL', '86400'); // 1 day
\go(function () use ($dbForPlatform, $queueForCertificates, $intervalRuleDomainVerification) {
\go(function () use ($dbForPlatform, $queueForCertificates, $intervalDomainVerification) {
Console::loop(function () use ($dbForPlatform, $queueForCertificates) {
$this->verifyDomain($dbForPlatform, $queueForCertificates);
}, $intervalRuleDomainVerification);
}, $intervalDomainVerification);
});
\go(function () use ($dbForPlatform, $queueForCertificates, $intervalRuleCertificateRenewal) {
\go(function () use ($dbForPlatform, $queueForCertificates, $intervalCertificateRenewal) {
Console::loop(function () use ($dbForPlatform, $queueForCertificates) {
$this->renewCertificates($dbForPlatform, $queueForCertificates);
}, $intervalRuleCertificateRenewal);
}, $intervalCertificateRenewal);
});
}
@@ -264,6 +264,7 @@ class Certificates extends Action
// Rule not found (or) not in the expected state
if ($rule->isEmpty() || $rule->getAttribute('status') !== RULE_STATUS_CERTIFICATE_GENERATING) {
Console::warning('Certificate generation for ' . $domain->get() . ' is skipped as the associated rule is either empty or not in the expected state.');
return;
}
// Get associated certificate for the rule