Note that there are some explanatory texts on larger screens.

plurals
  1. POCatch beanstalkd DEADLINE_SOON event in php
    text
    copied!<p>I'm using Beanstalkd message queue for ffmpeg processing video in my project. I use <a href="https://github.com/pda/pheanstalk" rel="nofollow">pheanstalk</a> PHP client for beanstalkd queue. My worker looks like:</p> <hr> <pre><code> ... // get latest job $job = $this->pheanstalk->reserve(); // get the data from the job $jobData = unserialize($job->getData()); // process job, giving a result $result = $this->task($jobData); if ($result) { // success = delete $this->pheanstalk->delete($job); } else { // failed = bury $this->pheanstalk->bury($job, 1024); } ... </code></pre> <p>In task() method I use smth like:</p> <pre><code> // video processing $processVideo = 'ffmpeg -vpre libx264-max -y -i inputfile ...'; shell_exec($processVideo); // taking screenshots from video ... </code></pre> <p>As you know, video processing can take long time, and sometimes it exceeds predefined job <strong>ttr</strong> (time to run). This way the job recieves time out event and comebacks to queue again. I run my worker several times at the same time for asynchronous processing. So the next free worker tries to take unfinished job. Finally, I have two or more processes under one video file. I think, I can define very long <strong>ttr</strong>, but it is not a good desigion. I've noticed, beanstalkd has DEADLINE_SOON event. But I don't know, how to catch it in my worker. I need it to have an ability to use <a href="https://github.com/pda/pheanstalk/blob/master/doc/protocol-1.3.txt#L302" rel="nofollow">"touch" command</a>.</p> <p>Do you have any advices?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload