some basic fixes for inbox and memcached queue handlers

This commit is contained in:
Evan Prodromou 2009-04-23 09:52:21 +00:00
parent ece70bf326
commit a3e727823d
2 changed files with 27 additions and 4 deletions

15
scripts/inboxqueuehandler.php Normal file → Executable file
View File

@ -29,6 +29,7 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
set_error_handler('common_error_handler'); set_error_handler('common_error_handler');
@ -39,12 +40,20 @@ class InboxQueueHandler extends QueueHandler
return 'inbox'; return 'inbox';
} }
function start() {
$this->log(LOG_INFO, "INITIALIZE");
return true;
}
function handle_notice($notice) function handle_notice($notice)
{ {
common_log(LOG_INFO, "Distributing notice to inboxes for $notice->id"); $this->log(LOG_INFO, "Distributing notice to inboxes for $notice->id");
$notice->addToInboxes(); $notice->addToInboxes();
return true; return true;
} }
function finish() {
}
} }
ini_set("max_execution_time", "0"); ini_set("max_execution_time", "0");
@ -52,6 +61,8 @@ ini_set("max_input_time", "0");
set_time_limit(0); set_time_limit(0);
mb_internal_encoding('UTF-8'); mb_internal_encoding('UTF-8');
$handler = new InboxQueueHandler($resource); $id = ($argc > 1) ? $argv[1] : null;
$handler = new InboxQueueHandler($id);
$handler->runOnce(); $handler->runOnce();

16
scripts/memcachedqueuehandler.php Normal file → Executable file
View File

@ -29,6 +29,7 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('LACONICA', true); define('LACONICA', true);
require_once(INSTALLDIR . '/lib/common.php'); require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/queuehandler.php');
set_error_handler('common_error_handler'); set_error_handler('common_error_handler');
@ -39,13 +40,22 @@ class MemcachedQueueHandler extends QueueHandler
return 'memcached'; return 'memcached';
} }
function start() {
$this->log(LOG_INFO, "INITIALIZE");
return true;
}
function handle_notice($notice) function handle_notice($notice)
{ {
// XXX: fork here // XXX: fork here
common_log(LOG_INFO, "Blowing memcached for $notice->id"); $this->log(LOG_INFO, "Blowing memcached for $notice->id");
$notice->blowCaches(); $notice->blowCaches();
return true; return true;
} }
function finish() {
}
} }
ini_set("max_execution_time", "0"); ini_set("max_execution_time", "0");
@ -53,6 +63,8 @@ ini_set("max_input_time", "0");
set_time_limit(0); set_time_limit(0);
mb_internal_encoding('UTF-8'); mb_internal_encoding('UTF-8');
$handler = new MemcachedQueueHandler($resource); $id = ($argc > 1) ? $argv[1] : null;
$handler = new MemcachedQueueHandler($id);
$handler->runOnce(); $handler->runOnce();