Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
}
],
"require": {
"php": ">=5.3.0",
"php": "^5.6 || ^7.1",
"ext-pcntl": "*",
"colinmollenhour/credis": "~1.7",
"psr/log": "1.0.*"
"psr/log": "~1.0"
},
"suggest": {
"ext-proctitle": "Allows php-resque to rename the title of UNIX processes to show the status of a worker.",
"ext-redis": "Native PHP extension for Redis connectivity. Credis will automatically utilize when available."
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
"phpunit/phpunit": "^5.7 || ^6.4"
},
"bin": [
"bin/resque"
Expand All @@ -37,5 +37,8 @@
"psr-0": {
"Resque": "lib"
}
},
"config": {
"sort-packages": true
}
}
11 changes: 6 additions & 5 deletions demo/bad_job.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

class Bad_PHP_Job
{
public function perform()
{
throw new Exception('Unable to run this job!');
}
}
public function perform()
{
throw new Exception('Unable to run this job!');
}
}
18 changes: 9 additions & 9 deletions demo/check_status.php
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,12 +12,12 @@
//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);
}
30 changes: 15 additions & 15 deletions demo/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
// Find and initialize Composer
// 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',
);
$files = [
__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
);
}
13 changes: 7 additions & 6 deletions demo/job.php
Original file line number Diff line number Diff line change
@@ -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);
}
}
11 changes: 6 additions & 5 deletions demo/long_job.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

class Long_PHP_Job
{
public function perform()
{
sleep(600);
}
}
public function perform()
{
sleep(600);
}
}
11 changes: 6 additions & 5 deletions demo/php_error_job.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

class PHP_Error_Job
{
public function perform()
{
callToUndefinedFunction();
}
}
public function perform()
{
callToUndefinedFunction();
}
}
18 changes: 9 additions & 9 deletions demo/queue.php
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,15 +12,15 @@
//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";
2 changes: 1 addition & 1 deletion demo/resque.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
require 'job.php';
require 'php_error_job.php';

require '../bin/resque';
require '../bin/resque';
74 changes: 37 additions & 37 deletions extras/sample-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@

class My_Resque_Plugin
{
public static function afterEnqueue($class, $arguments)
{
echo "Job was queued for " . $class . ". Arguments:";
print_r($arguments);
}
public static function beforeFirstFork($worker)
{
echo "Worker started. Listening on queues: " . implode(', ', $worker->queues(false)) . "\n";
}
public static function beforeFork($job)
{
echo "Just about to fork to run " . $job;
}
public static function afterFork($job)
{
echo "Forked to run " . $job . ". This is the child process.\n";
}
public static function beforePerform($job)
{
echo "Cancelling " . $job . "\n";
// throw new Resque_Job_DontPerform;
}
public static function afterPerform($job)
{
echo "Just performed " . $job . "\n";
}
public static function onFailure($exception, $job)
{
echo $job . " threw an exception:\n" . $exception;
}
}
public static function afterEnqueue($class, $arguments)
{
echo "Job was queued for " . $class . ". Arguments:";
print_r($arguments);
}

public static function beforeFirstFork($worker)
{
echo "Worker started. Listening on queues: " . implode(', ', $worker->queues(false)) . "\n";
}

public static function beforeFork($job)
{
echo "Just about to fork to run " . $job;
}

public static function afterFork($job)
{
echo "Forked to run " . $job . ". This is the child process.\n";
}

public static function beforePerform($job)
{
echo "Cancelling " . $job . "\n";
// throw new Resque_Job_DontPerform;
}

public static function afterPerform($job)
{
echo "Just performed " . $job . "\n";
}

public static function onFailure($exception, $job)
{
echo $job . " threw an exception:\n" . $exception;
}
}
Loading