EzDevInfo.com

php-resque

PHP port of resque (Workers and Queueing)

PHP-Resque failed jobs list

I have successfully integrated PHP RESQUE in my Ubuntu 14.

How can I get list of failed jobs in PHP to process them? I tried searching on web but could not find specific answer for PHP.

Please help. Thanks in advance.


Source: (StackOverflow)

How to get jobid from inside job in php-resque?

I'm having first steps with php-resque https://github.com/chrisboulton/php-resque . Anybody knows how can I get jobid inside Job Class ?


Source: (StackOverflow)

Advertisements

Password protect resque-web

I'm running php-resque with PHP and have installed resque-web to use the admin interface.

Problem: How do you password protect the resque-web pages? I am not familiar with Ruby/Rails/Sinatra so a solution that does not require much knowledge of them will be perfect!


Source: (StackOverflow)

How to manually prune and restart php-resque workers

Very frequently php-Resque workers will be stuck on a job for days, and eventually all the workers gets stuck and the site stops working.The php-resque library was installed using Composer.

Question: I want to do the pruning manually. How do I access this function pruneDeadWorkers()? And if dead workers are found, how do I restart them?

View Source

enter image description here


Source: (StackOverflow)

php-resque job perform function not executed?

I'm trying to make a background job with php-resque. I have this code:

\Resque::setBackend('127.0.0.1:6379');
\Resque::enqueue('default', '\BaseModule\Jobs\Mail',  array());

and in Mail class i have this

class Mail
{

   public function perform()
    {
            lakdf;  
    }
}

The mistake on "lakdf;" is here on purpose.

When I turn on monitor on my redis and try to execute job it write this:

1387283121.312817 [0 127.0.0.1:32827] "set" "resque:worker:michal-pc:9622:default" "{\"queue\":\"default\",\"run_at\":\"Tue Dec 17 12:25:21 UTC 2013\",\"payload\":{\"class\":\"\\\\BaseModule\\\\Jobs\\\\Mail\",\"args\":[[]],\"id\":\"c7c64e218bc951018c2a264eaf5a4b9a\"}}"
1387283121.313312 [0 127.0.0.1:32827] "incrby" "resque:stat:processed" "1"

So from the "reque:stat:processed" I think, that my job was processed, but there is a mistake in perform function and its not writing any error, like the perform function is never executed.

Even if I make some insert to database in perform function it will do nothing.

Does anybody know, where is problem? Why it seems that perform function is not executed?


Source: (StackOverflow)

PHP-Resque won't run perform()

I am using PHP-Resque and can't get the perform() method to work. Can anyone tell what I'm missing?

This is my setup:

  • I have 3 terminals open running the following:
  • $ php workers.php
  • $ redis-cli monitor
  • $ php create.php (To create a job)

  • workers.php

    <?php
    
    putenv("VVERBOSE=1");
    putenv("LOGGING=1");
    putenv("QUEUE=* php bin/resque"); 
    require_once APPPATH . '../vendor/chrisboulton/php-resque/bin/resque';
    
  • create.php

    <?php
    
    $jobId = Resque::enqueue('JESSE', 'Dog', ['hey'], true);
    echo "JobId: $jobId\n";
    
    $status = new Resque_Job_Status($jobId);
    if ($status->isTracking()) {
        echo "\nStatus: " . $status->get();
    }
    

I always get a JobId and Status of 1. eg:

JobId: 757335754aec172166e8679cc3bfef58
Status: 1

I always get a Redis log that its been inserted. eg:

[2 127.0.0.1:38912] "sadd" "resque:queues" "JESSE"
[2 127.0.0.1:38912] "rpush" "resque:queue:JESSE" "{\"class\":\"Dog\",\"args\":[[\"hey\"]],\"id\":\"757335754aec172166e8679cc3bfef58\"}"
[2 127.0.0.1:38912] "set" "resque:job:757335754aec172166e8679cc3bfef58:status" "{\"status\":1,\"updated\":1398269884,\"started\":1398269884}"
[2 127.0.0.1:38912] "exists" "resque:job:757335754aec172166e8679cc3bfef58:status"

Yet it doesn't seem to be running the perform() method at all:

class Dog {
    public function perform()
    {
        echo 'TEST TEST TEST TEST';

        fwrite('/tmp/resque-output.txt', 'This is running', w);
        fwrite(STDOUT, 'Start job! -> ');
        sleep(1);
        fwrite(STDOUT, 'Job ended!' . PHP_EOL);
    }
}

Source: (StackOverflow)

How to send email using php resque and redis

i am using redis and bcc resqueue to send the email but unable to send.how ever my service is being called but not sending the job. however getremider is being called but not able to send the email ,if i am calling getReminder() from api then email is sent. please help me.

thanks


Source: (StackOverflow)

How to cancel a job in PHP-RESQUE

I am using the below library

https://github.com/chrisboulton/php-resque

How to cancel the running job. I tried to get the worker object and kill the child..but the object does not have any child.


Source: (StackOverflow)

php - ./yiic rresque start does nothing

I installed this extension http://www.yiiframework.com/extension/yii-resque/

user@host:/path/to/protected$ ./yiic rresque start
Yii command runner (based on Yii v1.1.13)
Usage: ./yiic <command-name> [parameters...]

The following commands are available:
 - message
 - migrate
 - shell
 - webapp

To see individual command help, use the following:
   ./yiic help <command-name>

What's might be wrong?

EDIT

I figured out the problem: I didn't put RResqueCommand.php into ./protected/commands folder.


Source: (StackOverflow)

Optimising concurrent ImageMagick Requests using redis/php-resque

I am working on a site that uses ImageMagick to generate images. The site will get hundreds of request every minute and using ImageMagick to do this causes the site to crash.

So we implemented Redis and Php-resque to do the ImageMagick generating in the background on a seperate server so that it doesn't crash our main one. The problem is that it's still taking a very long time to get images done. A user might expect to wait up to 2-3 minutes for an image request because the server is so busy processing these images.

I am not sure what information to give you, but I'm more looking for advice. I think if we can cut down the initial process time for the ImageMagick request, then obviously this will help speed up the amount of images we can process.

Below is a sample of the ImageMagick script that we use:

convert -size 600x400 xc:none \( ".$path."assets/images/bases/base_image_69509021433289153_8_0.png -fill rgb\(255,15,127\) -colorize 100% \) -composite \( ".$path."assets/images/bases/eye_image_60444011438514404_8_0.png -fill rgb\(15,107,255\) -colorize 100% \) -composite \( ".$path."assets/images/markings/marking_clan_8_marking_10_1433289499.png -fill rgb\(255,79,79\) -colorize 100% \) -composite \( ".$path."assets/images/bases/shading_image_893252771433289153_8_0.png -fill rgb\(135,159,255\) -colorize 100% \) -compose Multiply -composite \( ".$path."assets/images/highlight_image_629750231433289153_8_0.png -fill rgb\(27,35,36\) -colorize 100% \) -compose Overlay -composite \( ".$path."assets/images/lineart_image_433715161433289153_8_0.png -fill rgb\(0,0,0\) -colorize 100% \) -compose Over -composite ".$path."assets/generated/queue/tempt_preview_27992_userid_0_".$filename."_file.png

My theory is that the reason this takes quite a long time is due to the process of colouring the images. Is there a way to optimise this process at all?

Anyone who has some experience with handling heavy loads of imagemagick processes or can see some glaringly easy ways to optimise our requests, I'd be very greatful.

Thank you :)


Source: (StackOverflow)

php-resque : Retry failed jobs

I have already setup php-resque on Laravel. Everything works great except failed jobs.

I can't see any option to requeue (retry) jobs that marked as failed.

I see that in redis db there is a queue named "failed" but how i can re-push each failed_job back to the parent queue?

I've searched everywhere (php-resque documentation, google etc..) but found nothing for php-resque. Only ready-made solution for ruby version...

Thanks in advance!


Source: (StackOverflow)

"Constant CRLF already defined" error when using php-resque with Laravel

I'm running php-resque together with Laravel 3 on Ubuntu 12.04.

Problem: When a job is enqueued in resque, I get the following error:

Unhandled Exception

Message:

Constant CRLF already defined
Location:

/var/www/dev/vendor/chrisboulton/php-resque/lib/Redisent/Redisent.php on line 10

What does the error mean and how can we solve it?

PHP

// Enqueue in Resque        
$data = array(
    'name'                  => $name,
    'email'                 => $email,
    'created_at'            => DB::raw('NOW()')
);
Resque::enqueue('queue', 'exampleWorker', $data);

However when I try to enqueue a job using artisan, it works!

Task

class Queue_Task
{
    public function run()
    {
        // Autoload composer vendors.
        require path('composer').DS.'autoload.php';

        $args = array('name' => 'John Smith');
        Resque::enqueue('MyAppName', 'ExampleWorker', $args);

        echo "Resque job queued.\n";
        return;
    }
}

Output

PHP Notice:  Constant CRLF already defined in /var/www/dev/vendor/chrisboulton/php-resque/lib/Redisent/Redisent.php on line 10

Notice: Constant CRLF already defined in /var/www/dev/vendor/chrisboulton/php-resque/lib/Redisent/Redisent.php on line 10
Resque job queued.

Source: (StackOverflow)

Scheduling a job after all jobs of a certain type are finished

I have a rather complex caching and invalidation setup where I need to recalculate a lot of data if a specific dataset changes.

Basically if one specific entry changes, this might create up to 15 jobs recalculating stuff. While those jobs are running, it could happen that another of the main entries changes. Again creating several jobs. (This could happen simultaneous)

What I need to achieve is to aggregate the results after the jobs are run. And it would probably make sense to do this aggregation only once.

So what I need to do is run a single job, only once after all those other jobs are finished.

(BTW: I am unsing BCCResqueuBundle)


Source: (StackOverflow)

unable to call illuminate class from resque worker

I have just started using resque in my application, I have created a worker and can queue jobs up. I am having issues though using illuminate classes in my worker. below is the error i am seeing in the worker.

PHP Fatal error:  Class 'Redis' not found in path/to/worker

Here is my worker class:

class SvrRestart {

    public function setUp() {
       // ... Set up environment for this job
    }

    public function perform() {
       $instance = $this->args['instance'];

       Redis::del('restart:' . $instance);

    }

    public function tearDown() {
    // ... Remove environment for this job
    }

}

I have also tried adding the following to the top of the worker:

use Illuminate\Support\Facades\Redis as Redis

this returns the following error:

PHP Fatal error:  Call to a member function del() on a non-object in    path/to/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 206

do I need to do something special to use illuminate classes in my worker?


Source: (StackOverflow)

php-resque : How to pause and stop a worker from php script

PHP-Resque workers can be started from a script with something like

passthru("nohup php " . __RESQUE_BIN__ . " >> " . __RESQUE_LOG__ . " 2>&1 &");

But how do i pause them, or stop them from a php script ?


Source: (StackOverflow)