summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-01-10 19:37:40 +0100
committerdefault <nobody@localhost>2024-01-10 19:37:40 +0100
commitfdb32864aa36e3e420083da8bfae45efa9eb743e (patch)
treef51baa1a4eb33105d7b3aaa954beb51295b8186c /main.c
parentdf266ecfb082efc21019574d4be29ff1e26c3dd1 (diff)
New command-line option 'state'.
Diffstat (limited to 'main.c')
-rw-r--r--main.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/main.c b/main.c
index f5fb0e9..08f23d5 100644
--- a/main.c
+++ b/main.c
@@ -4,6 +4,7 @@
#include "xs.h"
#include "xs_io.h"
#include "xs_json.h"
+#include "xs_time.h"
#include "snac.h"
@@ -22,6 +23,7 @@ int usage(void)
printf("deluser {basedir} {uid} Deletes a user\n");
printf("httpd {basedir} Starts the HTTPD daemon\n");
printf("purge {basedir} Purges old data\n");
+ printf("state {basedir} Prints server state\n");
printf("webfinger {basedir} {actor} Queries about an actor (@user@host or actor url)\n");
printf("queue {basedir} {uid} Processes a user queue\n");
printf("follow {basedir} {uid} {actor} Follows an actor\n");
@@ -138,6 +140,29 @@ int main(int argc, char *argv[])
return 0;
}
+ if (strcmp(cmd, "state") == 0) { /** **/
+ xs *shm_name = NULL;
+ srv_state *p_state = srv_state_op(&shm_name, 1);
+
+ if (p_state == NULL)
+ return 1;
+
+ srv_state ss = *p_state;
+ int n;
+
+ printf("server: %s (%s)\n", xs_dict_get(srv_config, "host"), USER_AGENT);
+ xs *uptime = xs_str_time_diff(time(NULL) - ss.srv_start_time);
+ printf("uptime: %s\n", uptime);
+ printf("job fifo size (cur): %d\n", ss.job_fifo_size);
+ printf("job fifo size (peak): %d\n", ss.peak_job_fifo_size);
+ char *th_states[] = { "stopped", "waiting", "input", "output" };
+
+ for (n = 0; n < ss.n_threads; n++)
+ printf("thread #%d state: %s\n", n, th_states[ss.th_state[n]]);
+
+ return 0;
+ }
+
if ((user = GET_ARGV()) == NULL)
return usage();