]> git.wh0rd.org - tt-rss.git/blobdiff - include/rssfuncs.php
unify houskeeping stuff, increase spawn interval
[tt-rss.git] / include / rssfuncs.php
index e9b9c71422f0649375c1fdf5916de4d3a5a5d781..a64d60e1eebbbc84ba29e89dcda4b7713cb035c1 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-       define('DAEMON_UPDATE_LOGIN_LIMIT', 30);
-       define('DAEMON_FEED_LIMIT', 100);
-       define('DAEMON_SLEEP_INTERVAL', 60);
+       define_default('DAEMON_UPDATE_LOGIN_LIMIT', 30);
+       define_default('DAEMON_FEED_LIMIT', 500);
+       define_default('DAEMON_SLEEP_INTERVAL', 120);
 
        function update_feedbrowser_cache() {
 
 
                // Test if feed is currently being updated by another process.
                if (DB_TYPE == "pgsql") {
-                       $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '5 minutes')";
+                       $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '10 minutes')";
                } else {
-                       $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))";
+                       $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 10 MINUTE))";
                }
 
                // Test if there is a limit to number of updated feeds
                $query_limit = "";
                if($limit) $query_limit = sprintf("LIMIT %d", $limit);
 
-               // We search for feed needing update.
-               $result = db_query("SELECT DISTINCT ttrss_feeds.feed_url
+               $query = "SELECT DISTINCT ttrss_feeds.feed_url, ttrss_feeds.last_updated
                        FROM
                                ttrss_feeds, ttrss_users, ttrss_user_prefs
                        WHERE
                                AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
                                $login_thresh_qpart $update_limit_qpart
                                $updstart_thresh_qpart
-                       ORDER BY last_updated $query_limit");
+                               ORDER BY last_updated $query_limit";
+
+               // We search for feed needing update.
+               $result = db_query($query);
 
                if($debug) _debug(sprintf("Scheduled %d feeds to update...", db_num_rows($result)));
 
                                WHERE feed_url IN (%s)", implode(',', $feeds_quoted)));
                }
 
-               expire_cached_files($debug);
-               expire_lock_files($debug);
-               expire_error_log($debug);
-
                $nf = 0;
 
                // For each feed, we call the feed update function.
        }
 
        function expire_lock_files($debug) {
-               if ($debug) _debug("Removing old lock files...");
+               //if ($debug) _debug("Removing old lock files...");
 
                $num_deleted = 0;
 
                        }
                }
 
-               if ($debug) _debug("Removed $num_deleted files.");
+               if ($debug) _debug("Removed $num_deleted old lock files.");
        }
 
        function expire_cached_files($debug) {
                foreach (array("simplepie", "images", "export", "upload") as $dir) {
                        $cache_dir = CACHE_DIR . "/$dir";
 
-                       if ($debug) _debug("Expiring $cache_dir");
+//                     if ($debug) _debug("Expiring $cache_dir");
 
                        $num_deleted = 0;
 
                                }
                        }
 
-                       if ($debug) _debug("Removed $num_deleted files.");
+                       if ($debug) _debug("$cache_dir: removed $num_deleted files.");
                }
        }
 
                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.");
+       }
 ?>