unify houskeeping stuff, increase spawn interval
This commit is contained in:
parent
654650857f
commit
e2cf81e214
|
@ -53,6 +53,10 @@ class Db implements IDb {
|
||||||
return("'$str'");
|
return("'$str'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reconnect() {
|
||||||
|
$this->link = $this->adapter->connect(DB_HOST, DB_USER, DB_PASS, DB_NAME, defined('DB_PORT') ? DB_PORT : "");
|
||||||
|
}
|
||||||
|
|
||||||
function connect($host, $user, $pass, $db, $port) {
|
function connect($host, $user, $pass, $db, $port) {
|
||||||
//return $this->adapter->connect($host, $user, $pass, $db, $port);
|
//return $this->adapter->connect($host, $user, $pass, $db, $port);
|
||||||
return ;
|
return ;
|
||||||
|
|
|
@ -368,14 +368,7 @@ class Handler_Public extends Handler {
|
||||||
include "rssfuncs.php";
|
include "rssfuncs.php";
|
||||||
// Update all feeds needing a update.
|
// Update all feeds needing a update.
|
||||||
update_daemon_common(0, true, false);
|
update_daemon_common(0, true, false);
|
||||||
|
housekeeping_common(false);
|
||||||
// Update feedbrowser
|
|
||||||
update_feedbrowser_cache();
|
|
||||||
|
|
||||||
// Purge orphans and cleanup tags
|
|
||||||
purge_orphans();
|
|
||||||
|
|
||||||
cleanup_tags(14, 50000);
|
|
||||||
|
|
||||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
||||||
|
|
||||||
|
|
|
@ -922,7 +922,7 @@
|
||||||
function get_schema_version($nocache = false) {
|
function get_schema_version($nocache = false) {
|
||||||
global $schema_version;
|
global $schema_version;
|
||||||
|
|
||||||
if (!$schema_version) {
|
if (!$schema_version && !$nocache) {
|
||||||
$result = db_query("SELECT schema_version FROM ttrss_version");
|
$result = db_query("SELECT schema_version FROM ttrss_version");
|
||||||
$version = db_fetch_result($result, 0, "schema_version");
|
$version = db_fetch_result($result, 0, "schema_version");
|
||||||
$schema_version = $version;
|
$schema_version = $version;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
define_default('DAEMON_UPDATE_LOGIN_LIMIT', 30);
|
define_default('DAEMON_UPDATE_LOGIN_LIMIT', 30);
|
||||||
define_default('DAEMON_FEED_LIMIT', 500);
|
define_default('DAEMON_FEED_LIMIT', 500);
|
||||||
define_default('DAEMON_SLEEP_INTERVAL', 60);
|
define_default('DAEMON_SLEEP_INTERVAL', 120);
|
||||||
|
|
||||||
function update_feedbrowser_cache() {
|
function update_feedbrowser_cache() {
|
||||||
|
|
||||||
|
@ -150,10 +150,6 @@
|
||||||
WHERE feed_url IN (%s)", implode(',', $feeds_quoted)));
|
WHERE feed_url IN (%s)", implode(',', $feeds_quoted)));
|
||||||
}
|
}
|
||||||
|
|
||||||
expire_cached_files($debug);
|
|
||||||
expire_lock_files($debug);
|
|
||||||
expire_error_log($debug);
|
|
||||||
|
|
||||||
$nf = 0;
|
$nf = 0;
|
||||||
|
|
||||||
// For each feed, we call the feed update function.
|
// For each feed, we call the feed update function.
|
||||||
|
@ -1374,4 +1370,17 @@
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function housekeeping_common($debug) {
|
||||||
|
expire_cached_files($debug);
|
||||||
|
expire_lock_files($debug);
|
||||||
|
expire_error_log($debug);
|
||||||
|
|
||||||
|
$count = update_feedbrowser_cache();
|
||||||
|
_debug("Feedbrowser updated, $count feeds processed.");
|
||||||
|
|
||||||
|
purge_orphans( true);
|
||||||
|
$rc = cleanup_tags( 14, 50000);
|
||||||
|
|
||||||
|
_debug("Cleaned $rc cached tags.");
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
21
update.php
21
update.php
|
@ -148,18 +148,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options["feeds"])) {
|
if (isset($options["feeds"])) {
|
||||||
// Update all feeds needing a update.
|
|
||||||
update_daemon_common();
|
update_daemon_common();
|
||||||
|
housekeeping_common(true);
|
||||||
// Update feedbrowser
|
|
||||||
$count = update_feedbrowser_cache();
|
|
||||||
_debug("Feedbrowser updated, $count feeds processed.");
|
|
||||||
|
|
||||||
// Purge orphans and cleanup tags
|
|
||||||
purge_orphans( true);
|
|
||||||
|
|
||||||
$rc = cleanup_tags( 14, 50000);
|
|
||||||
_debug("Cleaned $rc cached tags.");
|
|
||||||
|
|
||||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
||||||
}
|
}
|
||||||
|
@ -185,15 +175,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT);
|
update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT);
|
||||||
|
housekeeping_common(true);
|
||||||
|
|
||||||
$count = update_feedbrowser_cache();
|
|
||||||
_debug("Feedbrowser updated, $count feeds processed.");
|
|
||||||
|
|
||||||
purge_orphans( true);
|
|
||||||
|
|
||||||
$rc = cleanup_tags( 14, 50000);
|
|
||||||
|
|
||||||
_debug("Cleaned $rc cached tags.");
|
|
||||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,14 +170,15 @@
|
||||||
"Maybe another daemon is already running.\n");
|
"Maybe another daemon is already running.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
init_plugins();
|
|
||||||
|
|
||||||
$schema_version = get_schema_version();
|
$schema_version = get_schema_version();
|
||||||
|
|
||||||
if ($schema_version != SCHEMA_VERSION) {
|
if ($schema_version != SCHEMA_VERSION) {
|
||||||
die("Schema version is wrong, please upgrade the database.\n");
|
die("Schema version is wrong, please upgrade the database.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Protip: children close shared database handle when terminating, it's a bad idea to
|
||||||
|
// do database stuff on main process from now on.
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
// Since sleep is interupted by SIGCHLD, we need another way to
|
// Since sleep is interupted by SIGCHLD, we need another way to
|
||||||
|
@ -190,17 +191,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($last_checkpoint + $spawn_interval < time()) {
|
if ($last_checkpoint + $spawn_interval < time()) {
|
||||||
|
|
||||||
/* Check if schema version changed */
|
|
||||||
|
|
||||||
$test_schema_version = get_schema_version();
|
|
||||||
|
|
||||||
if ($test_schema_version != $schema_version) {
|
|
||||||
echo "Expected schema version: $schema_version, got: $test_schema_version\n";
|
|
||||||
echo "Schema version changed while we were running, bailing out\n";
|
|
||||||
exit(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
check_ctimes();
|
check_ctimes();
|
||||||
reap_children();
|
reap_children();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue