1
1
Fork 0

Add additional checks for the worker

This commit is contained in:
Michael 2017-09-30 11:19:46 +00:00
parent cc7d5602a9
commit bd88179419
5 changed files with 36 additions and 1 deletions

View file

@ -1086,6 +1086,11 @@ function proc_run($cmd) {
$parameters = json_encode($argv);
$found = dba::exists('workerqueue', array('parameter' => $parameters, 'done' => false));
// Quit if there was a database error - a precaution for the update process to 3.5.3
if (dba::errorNo() != 0) {
return;
}
if (!$found) {
dba::insert('workerqueue', array('parameter' => $parameters, 'created' => $created, 'priority' => $priority));
}

View file

@ -47,6 +47,7 @@ Example: To set the directory value please add this line to your .htconfig.php:
* **frontend_worker_timeout** - Value in minutes after we think that a frontend task was killed by the webserver. Default value is 10.
* **hsts** (Boolean) - Enables the sending of HTTP Strict Transport Security headers
* **ignore_cache** (Boolean) - For development only. Disables the item cache.
* **ipv4_resolve** (Boolean) - Resolve IPV4 addresses only. Don't resolve to IPV6. Default value is false.
* **like_no_comment** (Boolean) - Don't update the "commented" value of an item when it is liked.
* **local_block** (Boolean) - Used in conjunction with "block_public".
* **local_search** (Boolean) - Blocks search for users who are not logged in to prevent crawlers from blocking your system.

View file

@ -1259,6 +1259,24 @@ class dba {
return $data;
}
/**
* @brief Returns the error number of the last query
*
* @return string Error number (0 if no error)
*/
public static function errorNo() {
return self::$dbo->errorno;
}
/**
* @brief Returns the error message of the last query
*
* @return string Error message ('' if no error)
*/
public static function errorMessage() {
return self::$dbo->error;
}
/**
* @brief Closes the current statement
*

View file

@ -248,7 +248,9 @@ function poller_execute($queue) {
poller_exec_function($queue, $funcname, $argv);
$stamp = (float)microtime(true);
dba::update('workerqueue', array('done' => true), array('id' => $queue["id"]));
if (dba::update('workerqueue', array('done' => true), array('id' => $queue["id"]))) {
Config::set('system', 'last_poller_execution', datetime_convert());
}
$poller_db_duration = (microtime(true) - $stamp);
} else {
logger("Function ".$funcname." does not exist");

View file

@ -626,6 +626,15 @@ function admin_page_summary(App $a) {
$warningtext[] = t('The database update failed. Please run "php include/dbstructure.php update" from the command line and have a look at the errors that might appear.');
}
$last_worker_call = Config::get('system', 'last_poller_execution', false);
if (!$last_worker_call) {
$showwarning = true;
$warningtext[] = t('The worker was never executed. Please check your database structure!');
} elseif ((strtotime(datetime_convert()) - strtotime($last_worker_call)) > 60 * 60) {
$showwarning = true;
$warningtext[] = sprintf(t('The last worker execution was on %s UTC. This is older than one hour. Please check your crontab settings.'), $last_worker_call);
}
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
$accounts = array(
array(t('Normal Account'), 0),