aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Daemon')
-rw-r--r--Zotlabs/Daemon/Cache_query.php34
-rw-r--r--Zotlabs/Daemon/Expire.php8
2 files changed, 38 insertions, 4 deletions
diff --git a/Zotlabs/Daemon/Cache_query.php b/Zotlabs/Daemon/Cache_query.php
new file mode 100644
index 000000000..18d19cdf2
--- /dev/null
+++ b/Zotlabs/Daemon/Cache_query.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Zotlabs\Daemon;
+
+use Zotlabs\Lib\Cache;
+
+class Cache_query {
+
+ static public function run($argc, $argv) {
+
+ if(! $argc == 3)
+ return;
+
+ $key = $argv[1];
+
+ $pid = get_config('procid', $key, false);
+ if ($pid && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) {
+ logger($key . ': procedure already run with pid ' . $pid, LOGGER_DEBUG);
+ return;
+ }
+
+ $pid = getmypid();
+ set_config('procid', $key, $pid);
+
+ array_shift($argv);
+ array_shift($argv);
+
+ $r = call_user_func_array('q', $argv);
+ if($r)
+ Cache::set($key, serialize($r));
+
+ del_config('procid', $key);
+ }
+}
diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php
index 8ca92b6c5..c4ff8aec6 100644
--- a/Zotlabs/Daemon/Expire.php
+++ b/Zotlabs/Daemon/Expire.php
@@ -9,14 +9,14 @@ class Expire {
cli_startup();
- $pid = get_config('expire', 'procid', false);
+ $pid = get_config('procid', 'expire', false);
if ($pid && (function_exists('posix_kill') ? posix_kill($pid, 0) : true)) {
- logger('Expire: procedure already run with pid ' . $pid, LOGGER_DEBUG);
+ logger('procedure already run with pid ' . $pid, LOGGER_DEBUG);
return;
}
$pid = getmypid();
- set_config('expire', 'procid', $pid);
+ set_config('procid', 'expire', $pid);
// perform final cleanup on previously delete items
@@ -101,6 +101,6 @@ class Expire {
logger('Expire: sys: done', LOGGER_DEBUG);
}
- del_config('expire', 'procid');
+ del_config('procid', 'expire');
}
}