function cacheServerAll -- cache all server

pull/7420/head
Amaury Leroy 2021-05-19 14:55:19 +02:00
parent 282a9c4047
commit c34d320186
1 changed files with 28 additions and 0 deletions

View File

@ -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();