mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Port Certificates to new Queue system
This commit is contained in:
1 parent
674c23dfde
commit
21afa43127
9 files changed
+339
-308
No files matched your search
@@ -4,13 +4,15 @@ namespace Appwrite\Event;
|
||||
|
||||
use Resque;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Queue\Client;
|
||||
use Utopia\Queue\Connection;
|
||||
|
||||
class Certificate extends Event
|
||||
{
|
||||
protected bool $skipRenewCheck = false;
|
||||
protected ?Document $domain = null;
|
||||
|
||||
public function __construct()
|
||||
public function __construct(protected Connection $connection)
|
||||
{
|
||||
parent::__construct(Event::CERTIFICATES_QUEUE_NAME, Event::CERTIFICATES_CLASS_NAME);
|
||||
}
|
||||
@@ -69,7 +71,9 @@ class Certificate extends Event
|
||||
*/
|
||||
public function trigger(): string|bool
|
||||
{
|
||||
return Resque::enqueue($this->queue, $this->class, [
|
||||
$client = new Client($this->queue, $this->connection);
|
||||
|
||||
return $client->enqueue([
|
||||
'project' => $this->project,
|
||||
'domain' => $this->domain,
|
||||
'skipRenewCheck' => $this->skipRenewCheck
|
||||
|
||||
@@ -25,10 +25,11 @@ class Maintenance extends Action
|
||||
$this
|
||||
->desc('Schedules maintenance tasks and publishes them to resque')
|
||||
->inject('dbForConsole')
|
||||
->callback(fn (Database $dbForConsole) => $this->action($dbForConsole));
|
||||
->inject('queueForCertificates')
|
||||
->callback(fn (Database $dbForConsole, Certificate $queueForCertificates) => $this->action($dbForConsole, $queueForCertificates));
|
||||
}
|
||||
|
||||
public function action(Database $dbForConsole): void
|
||||
public function action(Database $dbForConsole, Certificate $queueForCertificates): void
|
||||
{
|
||||
Console::title('Maintenance V1');
|
||||
Console::success(APP_NAME . ' maintenance process v1 has started');
|
||||
@@ -80,7 +81,7 @@ class Maintenance extends Action
|
||||
->trigger();
|
||||
}
|
||||
|
||||
function renewCertificates($dbForConsole)
|
||||
function renewCertificates($dbForConsole, $queueForCertificates)
|
||||
{
|
||||
$time = DateTime::now();
|
||||
|
||||
@@ -91,12 +92,11 @@ class Maintenance extends Action
|
||||
]);
|
||||
|
||||
|
||||
if (\count($certificates) > 0) {
|
||||
if (\count($certificates) > 0 || true) {
|
||||
Console::info("[{$time}] Found " . \count($certificates) . " certificates for renewal, scheduling jobs.");
|
||||
|
||||
$event = new Certificate();
|
||||
foreach ($certificates as $certificate) {
|
||||
$event
|
||||
$queueForCertificates
|
||||
->setDomain(new Document([
|
||||
'domain' => $certificate->getAttribute('domain')
|
||||
]))
|
||||
@@ -135,7 +135,7 @@ class Maintenance extends Action
|
||||
$cacheRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days
|
||||
$schedulesDeletionRetention = (int) App::getEnv('_APP_MAINTENANCE_RETENTION_SCHEDULES', '86400'); // 1 Day
|
||||
|
||||
Console::loop(function () use ($interval, $executionLogsRetention, $abuseLogsRetention, $auditLogRetention, $cacheRetention, $schedulesDeletionRetention, $usageStatsRetentionHourly, $dbForConsole) {
|
||||
Console::loop(function () use ($interval, $executionLogsRetention, $abuseLogsRetention, $auditLogRetention, $cacheRetention, $schedulesDeletionRetention, $usageStatsRetentionHourly, $dbForConsole, $queueForCertificates) {
|
||||
$time = DateTime::now();
|
||||
|
||||
Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds");
|
||||
@@ -145,7 +145,7 @@ class Maintenance extends Action
|
||||
notifyDeleteUsageStats($usageStatsRetentionHourly);
|
||||
notifyDeleteConnections();
|
||||
notifyDeleteExpiredSessions();
|
||||
renewCertificates($dbForConsole);
|
||||
renewCertificates($dbForConsole, $queueForCertificates);
|
||||
notifyDeleteCache($cacheRetention);
|
||||
notifyDeleteSchedules($schedulesDeletionRetention);
|
||||
}, $interval);
|
||||
|
||||
Reference in new issue
Block a user