Browse Source

Add additional checks for the worker

pull/3747/head
Michael 3 years ago
parent
commit
bd88179419
5 changed files with 36 additions and 1 deletions
  1. +5
    -0
      boot.php
  2. +1
    -0
      doc/htconfig.md
  3. +18
    -0
      include/dba.php
  4. +3
    -1
      include/poller.php
  5. +9
    -0
      mod/admin.php

+ 5
- 0
boot.php 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));
}


+ 1
- 0
doc/htconfig.md 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.


+ 18
- 0
include/dba.php 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
*


+ 3
- 1
include/poller.php 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");


+ 9
- 0
mod/admin.php 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),


Loading…
Cancel
Save