Cron plugin added and now default queue handler
Generally the Cron plugin will run if there's still execution time for 1 second since starting the Action processing. If you want to change this (such as disabling, 0 seconds, or maybe running bigger chunks, for like 4 seconds) you can do this, where 'n' is time in seconds. addPlugin('Cron', array('secs_per_action', n)); Add 'rel_to_pageload'=>false to the array if you want to run the queue for a certain amount of seconds _despite_ maybe already having run that long in the previous parts of Action processing. Perhaps you want to run the cron script remotely, using a machine capable of background processing (or locally, to avoid running daemon processes), simply do an HTTP GET request to the route /main/cron of your GNU social. Setting secs_per_action to 0 in the plugin config will imply that you run all your queue handling by calling /main/cron (which runs as long as it can). /main/cron will output "0" if it has finished processing, "1" if it should be called again to complete processing (because it ran out of time due to PHP's max_execution_time INI setting). The Cron plugin also runs events as close to hourly, daily and weekly as you get, based on the opportunistic method of running whenever a user visits the site. This means of course that the cron events should be as fast as possible, not only to avoid delaying page load for users but also to minimize the risk of running into PHP's max_execution_time. One suggestion is to only use the events to add new queue items for later processing. These events are called CronHourly, CronDaily, CronWeekly - however there is no guarantee that all events will execute, so some kind of failsafe, transaction-ish method must be implemented in the future.
This commit is contained in:
parent
5998825458
commit
0cd93c2761
@ -233,6 +233,10 @@ StartEndHTML: just before the </html> tag
|
||||
EndEndHTML: just after the </html> tag
|
||||
- $action: action object being shown
|
||||
|
||||
FinalAction: After prepare() (and possible handle) in Action class.
|
||||
- $status: result of "prepare" call on action
|
||||
- $action: Action that is currently running
|
||||
|
||||
StartShowDesign: just before showing a site, user, or group design
|
||||
- $action: action object being shown
|
||||
|
||||
|
@ -117,9 +117,16 @@ class Action extends HTMLOutputter // lawsuit
|
||||
common_config_set('db', 'database', $mirror);
|
||||
}
|
||||
|
||||
if ($this->prepare($args)) {
|
||||
$status = $this->prepare($args);
|
||||
if ($status) {
|
||||
$this->handle($args);
|
||||
} else {
|
||||
common_debug('Prepare failed for Action.');
|
||||
}
|
||||
|
||||
$this->flush();
|
||||
|
||||
Event::handle('EndActionExecute', array($status, $this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,6 +294,7 @@ $default =
|
||||
'plugins' =>
|
||||
array('core' => array(
|
||||
'AuthCrypt' => array(),
|
||||
'Cron' => array(),
|
||||
'LRDD' => array(),
|
||||
'StrictTransportSecurity' => array(),
|
||||
),
|
||||
|
@ -67,6 +67,9 @@ abstract class QueueManager extends IoManager
|
||||
self::$qm = new UnQueueManager();
|
||||
} else {
|
||||
switch ($type) {
|
||||
case 'cron':
|
||||
self::$qm = new CronQueueManager();
|
||||
break;
|
||||
case 'db':
|
||||
self::$qm = new DBQueueManager();
|
||||
break;
|
||||
|
@ -37,7 +37,7 @@ require_once INSTALLDIR.'/scripts/commandline.inc';
|
||||
|
||||
$daemons = array();
|
||||
|
||||
$daemons[] = INSTALLDIR.'/scripts/queuedaemon.php';
|
||||
#$daemons[] = INSTALLDIR.'/scripts/queuedaemon.php';
|
||||
|
||||
if (Event::handle('GetValidDaemons', array(&$daemons))) {
|
||||
foreach ($daemons as $daemon) {
|
||||
|
Loading…
Reference in New Issue
Block a user