break; case 'closure-delayed': $job = Resque::later(mt_rand(0, 30), function ($job) { echo 'This is a delayed inline job! #' . $job->getId() . PHP_EOL; }); break; } } if ($job) { header('Location: ?id=' . $job->getId()); exit; } echo '<pre><h1><a href="?">php-resque</a></h1><ul>' . '<li><a href="?action=reset">Reset</a></li>' . '<li><a href="?action=push">Push new job</a></li>' . '<li><a href="?action=delayed">Delayed job</a></li>' . '<li><a href="?action=delayedat">Delayed job in 2 mins</a></li>' . '<li><a href="?action=longrunning">Long running job</a></li>' . '<li><a href="?action=faillong">Fail due to running too long</a></li>' . '<li><a href="?action=failnoclass">Fail due to no class being found</a></li>' . '<li><a href="?action=failexception">Fail due to exception</a></li>' . '<li><a href="?action=failerror">Fail due to fatal error</a></li>' . '<li><a href="?action=closure">Push closure</a></li>' . '<li><a href="?action=closure-delayed">Delayed closure</a></li>' . '</ul>'; $rep = 150; echo str_repeat('=', $rep) . PHP_EOL; echo 'Resque stats: ' . json_encode(Resque::stats()) . PHP_EOL; echo 'Hosts: ' . json_encode(Resque\Redis::instance()->smembers('hosts')) . PHP_EOL; echo 'Workers: ' . json_encode(Resque\Redis::instance()->smembers('workers')) . PHP_EOL; echo 'Queues: ' . json_encode(Resque\Redis::instance()->smembers('queues')) . PHP_EOL; echo 'Default queue: ' . json_encode(Resque\Redis::instance()->hgetall('queue:default:stats')) . PHP_EOL; echo 'Time: ' . json_encode(array(time(), date('r'))) . PHP_EOL; echo str_repeat('=', $rep) . PHP_EOL; $id = isset($_GET['id']) ? preg_replace('/[^0-9a-z]/i', '', $_GET['id']) : ''; if (!empty($id)) { if ($job = Resque::job($id)) { print_r($job->getPacket()); echo '<a href="?id=' . $id . '">Refresh</a>'; } else { echo 'Job #' . $id . ' not found'; } }