public function testStatusTrackingCanBeStopped() { Status::create('test'); $status = new Status('test'); $this->assertEquals(Status::STATUS_WAITING, $status->get()); $status->stop(); $this->assertFalse($status->get()); }
<?php require_once __DIR__ . '/../autoload.php'; use resque\Resque; use resque\core\job\Status; if (empty($argv[1])) { die('Specify the ID of a job to monitor the status of.'); } date_default_timezone_set('GMT'); Resque::setBackend('127.0.0.1:6379'); $status = new 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); }
/** * Return the status of the current job. * * @return int The status of the job as one of the Resque_Job_Status constants. */ public function getStatus() { $status = new Status($this->payload['id']); return $status->get(); }