Global reformat

This commit is contained in:
Daniel Mason 2018-05-25 21:03:48 +12:00
parent 14c0e26559
commit 51fda513f4
11 changed files with 532 additions and 533 deletions

View file

@ -1,6 +1,6 @@
<?php
if(empty($argv[1])) {
die('Specify the ID of a job to monitor the status of.');
if (empty($argv[1])) {
die('Specify the ID of a job to monitor the status of.');
}
require __DIR__ . '/init.php';
@ -12,12 +12,12 @@ Resque::setBackend('127.0.0.1:6379');
//Resque::setBackend('redis://user:pass@a.host.name:3432/2');
$status = new Resque_Job_Status($argv[1]);
if(!$status->isTracking()) {
die("Resque is not tracking the status of this job.\n");
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);
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);
}

View file

@ -3,23 +3,23 @@
// NOTE: You should NOT use this when developing against php-resque.
// The autoload code below is specifically for this demo.
$files = array(
__DIR__ . '/../../vendor/autoload.php',
__DIR__ . '/../../../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../vendor/autoload.php',
__DIR__ . '/../../../../autoload.php',
__DIR__ . '/../vendor/autoload.php',
);
$found = false;
foreach ($files as $file) {
if (file_exists($file)) {
require_once $file;
break;
}
if (file_exists($file)) {
require_once $file;
break;
}
}
if (!class_exists('Composer\Autoload\ClassLoader', false)) {
die(
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
'php composer.phar install' . PHP_EOL
);
die(
'You need to set up the project dependencies using the following commands:' . PHP_EOL .
'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
'php composer.phar install' . PHP_EOL
);
}

View file

@ -1,10 +1,11 @@
<?php
class PHP_Job
{
public function perform()
{
public function perform()
{
fwrite(STDOUT, 'Start job! -> ');
sleep(1);
fwrite(STDOUT, 'Job ended!' . PHP_EOL);
}
sleep(1);
fwrite(STDOUT, 'Job ended!' . PHP_EOL);
}
}

View file

@ -1,8 +1,9 @@
<?php
class Long_PHP_Job
{
public function perform()
{
sleep(600);
}
public function perform()
{
sleep(600);
}
}

View file

@ -1,8 +1,9 @@
<?php
class PHP_Error_Job
{
public function perform()
{
callToUndefinedFunction();
}
public function perform()
{
callToUndefinedFunction();
}
}

View file

@ -1,6 +1,6 @@
<?php
if(empty($argv[1])) {
die('Specify the name of a job to add. e.g, php queue.php PHP_Job');
if (empty($argv[1])) {
die('Specify the name of a job to add. e.g, php queue.php PHP_Job');
}
require __DIR__ . '/init.php';
@ -12,15 +12,15 @@ Resque::setBackend('127.0.0.1:6379');
//Resque::setBackend('redis://user:pass@a.host.name:3432/2');
$args = array(
'time' => time(),
'array' => array(
'test' => 'test',
),
'time' => time(),
'array' => array(
'test' => 'test',
),
);
if (empty($argv[2])) {
$jobId = Resque::enqueue('default', $argv[1], $args, true);
$jobId = Resque::enqueue('default', $argv[1], $args, true);
} else {
$jobId = Resque::enqueue($argv[1], $argv[2], $args, true);
$jobId = Resque::enqueue($argv[1], $argv[2], $args, true);
}
echo "Queued job ".$jobId."\n\n";
echo "Queued job " . $jobId . "\n\n";