Пример #1
0
<?php

if (!isset($_SERVER['RESQUE_JOB'])) {
    header('Status: 500 No Job');
    return;
}
require_once dirname(__FILE__) . '/../lib/Resque/Resque.php';
require_once dirname(__FILE__) . '/../lib/Resque/Worker.php';
if (isset($_SERVER['REDIS_BACKEND'])) {
    Resque\Resque::setBackend($_SERVER['REDIS_BACKEND']);
}
try {
    if (isset($_SERVER['APP_INCLUDE'])) {
        require_once $_SERVER['APP_INCLUDE'];
    }
    $job = unserialize(urldecode($_SERVER['RESQUE_JOB']));
    $job->worker->perform($job);
} catch (\Exception $e) {
    if (isset($job)) {
        $job->fail($e);
    } else {
        header('Status: 500');
    }
}
Пример #2
0
<?php

if (empty($argv[1])) {
    die('Specify the ID of a job to monitor the status of.');
}
require __DIR__ . '/init.php';
date_default_timezone_set('GMT');
Resque\Resque::setBackend('127.0.0.1:6379');
$status = new Resque\Job\Status($argv[1]);
if (!$status->isTracking()) {
    die("Resque is not tracking the status of this job.\n");
}
echo "Tracking status of " . $argv[1] . ". Press [break] to stop.\n\n";
while (true) {
    fwrite(STDOUT, "Status of " . $argv[1] . " is: " . $status->get() . "\n");
    sleep(1);
}
Пример #3
0
<?php

if (empty($argv[1])) {
    die('Specify the name of a job to add. e.g, php queue.php PHP_Job');
}
require __DIR__ . '/init.php';
date_default_timezone_set('GMT');
Resque\Resque::setBackend('127.0.0.1:6379');
$args = array('time' => time(), 'array' => array('test' => 'test'));
$jobId = Resque\Resque::enqueue('default', $argv[1], $args, true);
echo "Queued job " . $jobId . "\n\n";