diff --git a/.env b/.env index be0e5df718..4dd381cb82 100644 --- a/.env +++ b/.env @@ -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= diff --git a/Dockerfile b/Dockerfile index 71baa9e1c6..ecc5112cc4 100755 --- a/Dockerfile +++ b/Dockerfile @@ -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 && \ diff --git a/bin/interval b/bin/interval new file mode 100644 index 0000000000..e4355b1dc3 --- /dev/null +++ b/bin/interval @@ -0,0 +1,3 @@ +#!/bin/sh + +php /usr/src/code/app/cli.php interval $@ \ No newline at end of file diff --git a/bin/maintenance-rules b/bin/maintenance-rules deleted file mode 100644 index 666e517ca0..0000000000 --- a/bin/maintenance-rules +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -php /usr/src/code/app/cli.php maintenance-rules $@ \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 30b0737543..70650b0e57 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/src/Appwrite/Platform/Services/Tasks.php b/src/Appwrite/Platform/Services/Tasks.php index f585557690..a7854e5cb6 100644 --- a/src/Appwrite/Platform/Services/Tasks.php +++ b/src/Appwrite/Platform/Services/Tasks.php @@ -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()) diff --git a/src/Appwrite/Platform/Tasks/MaintenanceRules.php b/src/Appwrite/Platform/Tasks/Interval.php similarity index 85% rename from src/Appwrite/Platform/Tasks/MaintenanceRules.php rename to src/Appwrite/Platform/Tasks/Interval.php index cbcd538d8c..74ab9db1f1 100644 --- a/src/Appwrite/Platform/Tasks/MaintenanceRules.php +++ b/src/Appwrite/Platform/Tasks/Interval.php @@ -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); }); } diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 6371f6c313..0c4d495724 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -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