From 4b3979df04e0cba12049dced3ba037a004c324f6 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 3 Apr 2020 10:49:57 +0200 Subject: Avoid multiple run of expiry procedure on large sites --- Zotlabs/Daemon/Expire.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Zotlabs/Daemon') diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 398425861..f3f42df6f 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -8,6 +8,13 @@ class Expire { static public function run($argc,$argv){ cli_startup(); + + if ($pid = get_config('expire', 'procid', false) && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) { + logger('Expire: procedure already run with PID ' . $pid, LOGGER_DEBUG); + return; + } + + set_config('expire', 'procid', getmypid()); // perform final cleanup on previously delete items @@ -90,5 +97,7 @@ class Expire { logger('Expire: sys: done', LOGGER_DEBUG); } + + del_config('expire', 'procid'); } } -- cgit v1.2.3