summaryrefslogtreecommitdiffstats
path: root/daemon/bindings/worker.rst
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:26:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:26:00 +0000
commit830407e88f9d40d954356c3754f2647f91d5c06a (patch)
treed6a0ece6feea91f3c656166dbaa884ef8a29740e /daemon/bindings/worker.rst
parentInitial commit. (diff)
downloadknot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.tar.xz
knot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.zip
Adding upstream version 5.6.0.upstream/5.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/bindings/worker.rst')
-rw-r--r--daemon/bindings/worker.rst35
1 files changed, 35 insertions, 0 deletions
diff --git a/daemon/bindings/worker.rst b/daemon/bindings/worker.rst
new file mode 100644
index 0000000..9dfcbe8
--- /dev/null
+++ b/daemon/bindings/worker.rst
@@ -0,0 +1,35 @@
+.. SPDX-License-Identifier: GPL-3.0-or-later
+
+Scripting worker
+^^^^^^^^^^^^^^^^
+
+Worker is a service over event loop that tracks and schedules outstanding queries,
+you can see the statistics or schedule new queries. It also contains information about
+specified worker count and process rank.
+
+.. envvar:: worker.id
+
+ Value from environment variable ``SYSTEMD_INSTANCE``,
+ or if it is not set, :envvar:`PID <worker.pid>` (string).
+
+.. envvar:: worker.pid
+
+ Current worker process PID (number).
+
+.. function:: worker.stats()
+
+ Return table of statistics. See member descriptions in :c:type:`worker_stats`.
+ A few fields are added, mainly from POSIX ``getrusage()``:
+
+ * ``usertime`` and ``systime`` -- CPU time used, in seconds
+ * ``pagefaults`` -- the number of hard page faults, i.e. those that required I/O activity
+ * ``swaps`` -- the number of times the process was “swapped” out of main memory; unused on Linux
+ * ``csw`` -- the number of context switches, both voluntary and involuntary
+ * ``rss`` -- current memory usage in bytes, including whole cache (resident set size)
+
+ Example:
+
+ .. code-block:: lua
+
+ print(worker.stats().concurrent)
+