public function restIndexQueue() { $config = Api::_()->getConfig(); $defaultQueues = $config['queue']['default_queues']; $queues = array_merge($defaultQueues, \Resque::queues()); $queues = array_unique($queues); foreach ($queues as $key => $queue) { $queues[$key] = array('name' => $queue, 'size' => \Resque::size($queue)); } $pslist = $this->getSystemProcessList('ps ux | grep "php ' . realpath(EVA_ROOT_PATH . '/workers') . '" | grep -v grep'); foreach ($queues as $key => $queue) { $workerCount = 0; foreach ($pslist as $psKey => $ps) { $offset = strlen($ps['COMMAND']) - strlen($queue['name']); if ($offset === strrpos($ps['COMMAND'], $queue['name'])) { $workerCount++; unset($pslist[$psKey]); } } $queues[$key]['workers'] = $workerCount; } $publicWorkerCount = count($pslist); $return = array('items' => $queues, 'publicWorkerCount' => $publicWorkerCount); if ($this->params()->fromQuery('format') == 'json') { $this->changeViewModel('json'); return new JsonModel($return); } return $return; }
/** * @return ArrayList */ protected function getQueues() { $queues = Resque::queues(); $queueList = new ArrayList(); foreach ($queues as $idx => $queue) { $queueList->push(new ResqueQueue(array('ID' => $idx + 1, 'Name' => $queue, 'Size' => Resque::size($queue)))); } return $queueList; }
/** * Get jobs for the given queue. * * @param string $queue The name of the queue or "*" for all queues * * @return array|\Resque_Job[] */ public function getJobs($queue = null) { if (!$queue || $queue === '*') { $queues = \Resque::queues(); $jobs = array(); foreach ($queues as $queue) { $jobs = array_merge($jobs, $this->getJobs($queue)); } return $jobs; } return array_map(function ($job) use($queue) { return new \Resque_Job($queue, json_decode($job, true)); }, \Resque::redis()->lrange('queue:' . $queue, 0, -1)); }
public function jobs(Request $request, Response $response, array $args) { $settings = loadsettings(); $REDIS_BACKEND = $settings['resque']['REDIS_BACKEND']; if (!empty($REDIS_BACKEND)) { \Resque::setBackend($REDIS_BACKEND); } $queues = []; $queuenames = \Resque::queues(); sort($queuenames); foreach ($queuenames as $queue) { $size = \Resque::size($queue); $queues[] = ['name' => $queue, 'size' => $size, 'jobs' => $this->peek($queue)]; } $data['queues'] = $queues; $this->view->render($response, 'queues.twig', $data); return $response; }
public function actionQueues() { $redisQueues = []; $queues = \Resque::queues(); $redis = $this->getRedis(); // $queues = $redis->lrange('queue:default', 0,-1); if ($queues) { foreach ($queues as $queue) { $key = 'queue:' . $queue; $redisQueues[$queue] = $redis->lrange($key, 0, -1); } foreach ($redisQueues as $queue => $redisQueue) { foreach ($redisQueue as $index => $que) { $redisQueues[$queue][$index] = json_decode($que, true); } } } return $this->render('queues', ['queues' => $redisQueues]); }
<?php /** * Created by PhpStorm. * User: viniciusthiengo * Date: 7/23/15 * Time: 10:50 AM */ require '../vendor/autoload.php'; require 'EchoData.php'; //include date_default_timezone_set('GMT'); Resque::setBackend('127.0.0.1:6379'); $args = array('name' => 'Thiengo'); $jobId = Resque::enqueue('default', 'EchoData', $args, true); echo "Queued job " . $jobId . "<br><br>"; $status = new Resque_Job_Status($jobId); if (!$status->isTracking()) { die("Resque is not tracking the status of this job.\n"); } echo $status . '<br><br>'; $jobId = Resque::enqueue('cms26', 'EchoData2', $args); //exec('echo "create-file.php" | atnow'); //exec('php "create-file.php" | atnow'); echo 'file has being created <br><br>'; //Resque::pop('notification'); echo Resque::size('default'); print_r(Resque::queues());
/** * Returns an error message if redis is unavailable * * @return string */ public static function RedisUnavailable() { try { Resque::queues(); } catch (Exception $e) { return $e->getMessage(); } return ''; }
public function testJobWithNamespace() { Resque::setBackend(REDIS_HOST, REDIS_DATABASE, 'php'); $queue = 'jobs'; $payload = array('another_value'); Resque::enqueue($queue, 'Test_Job_With_TearDown', $payload); $this->assertEquals(Resque::queues(), array('jobs')); $this->assertEquals(Resque::size($queue), 1); Resque::setBackend(REDIS_HOST, REDIS_DATABASE, REDIS_NAMESPACE); $this->assertEquals(Resque::size($queue), 0); }
/** * Return an array containing all of the queues that this worker should use * when searching for jobs. * * If * is found in the list of queues, every queue will be searched in * alphabetic order. (@see $fetch) * * @param boolean $fetch If true, and the queue is set to *, will fetch * all queue names from redis. * @return array Array of associated queues. */ public function queues($fetch = true) { if (!in_array('*', $this->queues) || $fetch == false) { return $this->queues; } $queues = Resque::queues(); sort($queues); return $queues; }
public function testJobWithNamespace() { Resque_Redis::prefix('php'); $queue = 'jobs'; $payload = array('another_value'); Resque::enqueue($queue, 'Test_Job_With_TearDown', $payload); $this->assertEquals(Resque::queues(), array('jobs')); $this->assertEquals(Resque::size($queue), 1); Resque_Redis::prefix('resque'); $this->assertEquals(Resque::size($queue), 0); }
public function getQueues() { return \array_map(function ($queue) { return new Queue($queue); }, \Resque::queues()); }
/** * Get the queues's names. * * @return array Array containing the queues' names. * @see CakeResqueShell::clear() * @see CakeResqueShell::stats() * @codeCoverageIgnore */ public static function getQueues() { return Resque::queues(); }
/** * Return an array containing all of the queues that this worker should use * when searching for jobs. * * If * is found in the list of queues, every queue will be searched in * alphabetic order. (@see $fetch) * * @param boolean $fetch If true, and the queue is set to *, will fetch * all queue names from redis. * @return array Array of associated queues. */ public function queues($fetch = true) { if ($fetch == false) { return $this->queues; } $user_queues = implode('|', $this->queues); if (strpos($user_queues, '*') === FALSE) { return $this->queues; } $queues = Resque::queues(); sort($queues); if (in_array('*', $this->queues)) { return $queues; } $matching_queues = []; $user_queues_regexp = []; foreach ($this->queues as $queue) { if (strpos($queue, '*') === FALSE) { $matching_queues[] = $queue; } else { foreach ($queues as $rqueue) { if (fnmatch($queue, $rqueue)) { $matching_queues[] = $rqueue; } } } } return $matching_queues; }