From c34d3201865aacd8d82da404da96a7a4bcc01128 Mon Sep 17 00:00:00 2001 From: Amaury Leroy Date: Wed, 19 May 2021 14:55:19 +0200 Subject: [PATCH] function cacheServerAll -- cache all server --- app/Console/Command/ServerShell.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/Console/Command/ServerShell.php b/app/Console/Command/ServerShell.php index 05ac12536..cf49406e3 100644 --- a/app/Console/Command/ServerShell.php +++ b/app/Console/Command/ServerShell.php @@ -320,6 +320,34 @@ class ServerShell extends AppShell echo $message . PHP_EOL; } + public function cacheServerAll() + { + $this->ConfigLoad->execute(); + + $userId = $this->args[0]; + $user = $this->User->getAuthUser($userId); + if (empty($user)) { + die('User ID do not match an existing user.' . PHP_EOL); + } + + $servers = $this->Server->find('all', array( + 'conditions' => array('Server.pull' => 1), + 'recursive' => -1, + 'order' => 'Server.priority', + 'fields' => array('Server.name', 'Server.id'), + )); + + foreach ($servers as $server) { + $jobId = CakeResque::enqueue( + 'default', + 'ServerShell', + array('cacheServer', $userId, $server['Server']['id']) + ); + $this->out("Enqueued cacheServer from {$server['Server']['name']} server as job $jobId"); + } + + } + public function cacheFeed() { $this->ConfigLoad->execute();