From ab2d830cc0357b1ec6ae8ba00f1d04aba19f2e70 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 24 Jan 2024 17:44:29 +0000 Subject: [PATCH] Address comments --- Dockerfile | 2 +- bin/queue-retry | 3 +++ bin/retry-jobs | 3 --- src/Appwrite/Platform/Tasks/RetryJobs.php | 20 +++++++++++++++++++- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 bin/queue-retry delete mode 100644 bin/retry-jobs diff --git a/Dockerfile b/Dockerfile index 385f53a144..e39890dd60 100755 --- a/Dockerfile +++ b/Dockerfile @@ -85,7 +85,7 @@ RUN chmod +x /usr/local/bin/doctor && \ chmod +x /usr/local/bin/ssl && \ chmod +x /usr/local/bin/test && \ chmod +x /usr/local/bin/vars && \ - chmod +x /usr/local/bin/retry-jobs && \ + chmod +x /usr/local/bin/queue-retry && \ chmod +x /usr/local/bin/worker-audits && \ chmod +x /usr/local/bin/worker-certificates && \ chmod +x /usr/local/bin/worker-databases && \ diff --git a/bin/queue-retry b/bin/queue-retry new file mode 100644 index 0000000000..f9473e6b07 --- /dev/null +++ b/bin/queue-retry @@ -0,0 +1,3 @@ +#!/bin/sh + +php /usr/src/code/app/cli.php queue-retry $@ \ No newline at end of file diff --git a/bin/retry-jobs b/bin/retry-jobs deleted file mode 100644 index afc78aacf3..0000000000 --- a/bin/retry-jobs +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -php /usr/src/code/app/cli.php retry-jobs $@ \ No newline at end of file diff --git a/src/Appwrite/Platform/Tasks/RetryJobs.php b/src/Appwrite/Platform/Tasks/RetryJobs.php index 5167b899b2..90a9bceefb 100644 --- a/src/Appwrite/Platform/Tasks/RetryJobs.php +++ b/src/Appwrite/Platform/Tasks/RetryJobs.php @@ -2,11 +2,14 @@ namespace Appwrite\Platform\Tasks; +use Appwrite\Event\Event; +use Twig\Node\Expression\Test\EvenTest; use Utopia\CLI\Console; use Utopia\Platform\Action; use Utopia\Queue\Client; use Utopia\Queue\Connection; use Utopia\Validator\Text; +use Utopia\Validator\WhiteList; class RetryJobs extends Action { @@ -20,7 +23,20 @@ class RetryJobs extends Action { $this ->desc('Retry failed jobs from a specific queue identified by the name parameter') - ->param('name', '', new Text(128), 'Queue name') + ->param('name', '', new WhiteList([ + Event::DATABASE_QUEUE_NAME, + Event::DELETE_QUEUE_NAME, + Event::AUDITS_QUEUE_NAME, + Event::MAILS_QUEUE_NAME, + Event::FUNCTIONS_QUEUE_NAME, + Event::USAGE_QUEUE_NAME, + Event::WEBHOOK_CLASS_NAME, + Event::CERTIFICATES_QUEUE_NAME, + Event::BUILDS_QUEUE_NAME, + Event::MESSAGING_QUEUE_NAME, + Event::MIGRATIONS_QUEUE_NAME, + Event::HAMSTER_CLASS_NAME + ]), 'Queue name') ->inject('queue') ->callback(fn ($name, $queue) => $this->action($name, $queue)); } @@ -43,6 +59,8 @@ class RetryJobs extends Action return; } + Console::log('Retrying failed jobs...'); + $queueClient->retry(); } }