Merge pull request #3747 from annando/additional-checks

Add additional checks for the worker
This commit is contained in:
Tobias Diekershoff 2017-09-30 13:37:32 +02:00 committed by GitHub
commit 01c2452547
5 changed files with 36 additions and 1 deletions

View File

@ -1086,6 +1086,11 @@ function proc_run($cmd) {
$parameters = json_encode($argv); $parameters = json_encode($argv);
$found = dba::exists('workerqueue', array('parameter' => $parameters, 'done' => false)); $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) { if (!$found) {
dba::insert('workerqueue', array('parameter' => $parameters, 'created' => $created, 'priority' => $priority)); 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. * **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 * **hsts** (Boolean) - Enables the sending of HTTP Strict Transport Security headers
* **ignore_cache** (Boolean) - For development only. Disables the item cache. * **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. * **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_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. * **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; 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 * @brief Closes the current statement
* *

View File

@ -248,7 +248,9 @@ function poller_execute($queue) {
poller_exec_function($queue, $funcname, $argv); poller_exec_function($queue, $funcname, $argv);
$stamp = (float)microtime(true); $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); $poller_db_duration = (microtime(true) - $stamp);
} else { } else {
logger("Function ".$funcname." does not exist"); 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.'); $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`"); $r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
$accounts = array( $accounts = array(
array(t('Normal Account'), 0), array(t('Normal Account'), 0),