From 1fefb7e133150b5d7d6e61a45cd4daf12e66f733 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:01:23 +0530 Subject: [PATCH 1/4] Add a 20 second delay to maintenance worker --- .env | 1 + docker-compose.yml | 1 + src/Appwrite/Platform/Tasks/Maintenance.php | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 31474bf0b6..0660bdc8b5 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=20 _APP_MAINTENANCE_RETENTION_CACHE=2592000 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 _APP_MAINTENANCE_RETENTION_ABUSE=86400 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 From 8ed5489d9ce414728bc64eaff1843de8f42f319b Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:11:37 +0530 Subject: [PATCH 2/4] Added env variable to variables.php and compose.phtml --- app/config/variables.php | 9 +++++++++ app/views/install/compose.phtml | 1 + 2 files changed, 10 insertions(+) diff --git a/app/config/variables.php b/app/config/variables.php index 533a85a840..af55fdb6d0 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 20 seconds.', + 'introduction' => '1.5.0', + 'default' => '20', + '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 From bb920740933e83fac84d72019a5bf30c8d352428 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 6 Feb 2024 22:26:40 +0530 Subject: [PATCH 3/4] Update .env --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 0660bdc8b5..0247356a25 100644 --- a/.env +++ b/.env @@ -73,7 +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=20 +_APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 _APP_MAINTENANCE_RETENTION_ABUSE=86400 From 4dee937e360d964da041d3045c3476a73c755690 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 6 Feb 2024 22:26:47 +0530 Subject: [PATCH 4/4] Update app/config/variables.php --- app/config/variables.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index af55fdb6d0..ffc3cb998d 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -950,9 +950,9 @@ return [ ], [ '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 20 seconds.', + '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' => '20', + 'default' => '0', 'required' => false, 'question' => '', 'filter' => ''