diff --git a/.env b/.env index 31474bf0b6..0247356a25 100644 --- a/.env +++ b/.env @@ -73,6 +73,7 @@ _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://proxy/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 _APP_MAINTENANCE_INTERVAL=86400 +_APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 _APP_MAINTENANCE_RETENTION_ABUSE=86400 diff --git a/app/config/variables.php b/app/config/variables.php index 533a85a840..ffc3cb998d 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -948,6 +948,15 @@ return [ 'question' => '', 'filter' => '' ], + [ + 'name' => '_APP_MAINTENANCE_DELAY', + 'description' => 'Delay value containing the number of seconds that the Appwrite maintenance process should wait before executing system cleanups and optimizations. The default value is 0 seconds.', + 'introduction' => '1.5.0', + 'default' => '0', + 'required' => false, + 'question' => '', + 'filter' => '' + ], [ 'name' => '_APP_MAINTENANCE_RETENTION_CACHE', 'description' => 'The maximum duration (in seconds) upto which to retain cached files. The default value is 2592000 seconds (30 days).', diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 3e227c1fc2..d1fd15a1b7 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -143,6 +143,7 @@ services: - _APP_LOGGING_PROVIDER - _APP_LOGGING_CONFIG - _APP_MAINTENANCE_INTERVAL + - _APP_MAINTENANCE_DELAY - _APP_MAINTENANCE_RETENTION_EXECUTION - _APP_MAINTENANCE_RETENTION_CACHE - _APP_MAINTENANCE_RETENTION_ABUSE diff --git a/docker-compose.yml b/docker-compose.yml index 395923681d..e8433608d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -645,6 +645,7 @@ services: - _APP_MAINTENANCE_RETENTION_AUDIT - _APP_MAINTENANCE_RETENTION_USAGE_HOURLY - _APP_MAINTENANCE_RETENTION_SCHEDULES + - _APP_MAINTENANCE_DELAY appwrite-worker-usage: entrypoint: worker-usage diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index 02198d26ca..8a263ac276 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -36,6 +36,7 @@ class Maintenance extends Action // # of days in seconds (1 day = 86400s) $interval = (int) App::getEnv('_APP_MAINTENANCE_INTERVAL', '86400'); + $delay = (int) App::getEnv('_APP_MAINTENANCE_DELAY', '0'); $usageStatsRetentionHourly = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_HOURLY', '8640000'); //100 days $cacheRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days $schedulesDeletionRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_SCHEDULES', '86400'); // 1 Day @@ -59,7 +60,7 @@ class Maintenance extends Action $this->renewCertificates($dbForConsole, $queueForCertificates); $this->notifyDeleteCache($cacheRetention, $queueForDeletes); $this->notifyDeleteSchedules($schedulesDeletionRetention, $queueForDeletes); - }, $interval); + }, $interval, $delay); } protected function foreachProject(Database $dbForConsole, callable $callback): void