beanstalkd currently does not work properly. runqueue and drush command make some php errors.

Comments

egruel’s picture

Title: beanstalkd currently does not work » Run runqueue & drush command.
egruel’s picture

This patch resolve this problem and permit to run runqueue & drush command.

gordon’s picture

Status: Active » Needs work

Thanks for this.

Can you please post the errors that you are getting so I can see what you are trying to fix, and secondly can you please not include the trimming of the tailing whitespace. I would like to get rid of them but they are just clogging up the patch.

Thanks again.
Gordon

kscheirer’s picture

Issue summary: View changes
Priority: Major » Normal
Status: Needs work » Postponed (maintainer needs more info)

You'll probably have to reroll this anyway if #2133737: [tsm] Code style cleanup from pareview.sh goes in. Error messages would be very useful!

I think these are the only lines that were actually being changed in beanstalkd_process_item():

- global $queue;
+ global $queue, $names, $hostname;

if (!empty($info)) {
- $function = $info['worker callback'];
+ $function = $info[$hostname][reset($names)]['worker callback'];

- $function($item->data);
+ $function($item->beanstalkd_job->getData());

gordon’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.72 KB

I have rerolled the patch, but I have not yet appied it.

gordon’s picture

Status: Needs review » Needs work
  1. +++ b/runqueue.sh
    @@ -114,12 +114,12 @@ function beanstalkd_process($allow_forking = TRUE, $process_time = FALSE, $proce
    -  global $queue;
    +  global $queue, $names, $hostname;
     
       $info = beanstalkd_get_host_queues(NULL, $item->name);
     
       if (!empty($info)) {
    -    $function = $info['worker callback'];
    +    $function = $info[$hostname][reset($names)]['worker callback'];
    

    I am not sure why this is being done, because when you call beanstalkd_get_host_queues() and pass a queue name it will just return that queue and nothing more.

  2. +++ b/runqueue.sh
    @@ -129,7 +129,7 @@ function beanstalkd_process_item($item) {
    -      $function($item->data);
    +      $function($item->beanstalkd_job->getData());
    

    This will actually pass a serialised version of the data to the function. $item->data is an unserialised version.

I have committed the changes to drush as they we can issues, but I need more information on why the changes were made for runqueue.sh

egruel’s picture

Hi gordon,

Sorry for my late reply, as said "kscheirer" the only lines that were actually being changed in beanstalkd_process_item() are:

- global $queue;
+ global $queue, $names, $hostname;

if (!empty($info)) {
- $function = $info['worker callback'];
+ $function = $info[$hostname][reset($names)]['worker callback'];

- $function($item->data);
+ $function($item->beanstalkd_job->getData());

Sorry for my english but I' will try to give you more information to explain why i want do that's.

I have declare one queue in drupal like that :


function my_module_cron_queue_info() {
  $queue = array();

  $queue['my_queue'] = array(
    'worker callback' => '_my_module_process_queue',
    'time' => '60',
  );
  return $queue;
}

I launch beanstalk with this command :

beanstalkd -l 127.0.0.1 -p 11300z 1048576 -b /var/tmp

And run the script run_queue.sh :

./runqueue.sh -c 127.0.0.1 -p 11300 -q my_queue

After I simulate a push on my queue like that :

curl -d @my_file.xml "http://push.local.mysite.fr/my_queue"

And i got this error, in shell :

PHP Fatal error: Function name must be a string in /var/www/francetv_sport/public/sites/all/modules/contrib/beanstalkd/runqueue.sh on line 132

When i change those lines, i have no error and "my_file.xml" is correctly push and process by my function "_my_module_process_queue".

ps: I have uptated my module with rc4 before re-make the patch

egruel’s picture

Gordon,

I will send you a new patch, but i see you have already add this change in your patch, so for me this issue is resolve.

Thank you

egruel’s picture

Status: Needs work » Closed (fixed)