function pushAll -- push all servers

pull/7420/head
Amaury Leroy 2021-05-19 14:59:23 +02:00
parent c34d320186
commit 987473a7fe
1 changed files with 27 additions and 0 deletions

View File

@ -212,6 +212,33 @@ class ServerShell extends AppShell
}
}
public function pushAll()
{
$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.push' => 1),
'recursive' => -1,
'order' => 'Server.priority',
'fields' => array('Server.name', 'Server.id'),
));
foreach ($servers as $server) {
$jobId = CakeResque::enqueue(
'default',
'ServerShell',
array('push', $userId, $server['Server']['id'], $technique)
);
$this->out("Enqueued pushing from {$server['Server']['name']} server as job $jobId");
}
}
public function fetchFeed()
{
$this->ConfigLoad->execute();