diff options
| author | 2024-01-10 19:37:40 +0100 | |
|---|---|---|
| committer | 2024-01-10 19:37:40 +0100 | |
| commit | fdb32864aa36e3e420083da8bfae45efa9eb743e (patch) | |
| tree | f51baa1a4eb33105d7b3aaa954beb51295b8186c /main.c | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | snac2-fdb32864aa36e3e420083da8bfae45efa9eb743e.tar.gz snac2-fdb32864aa36e3e420083da8bfae45efa9eb743e.tar.xz snac2-fdb32864aa36e3e420083da8bfae45efa9eb743e.zip | |
New command-line option 'state'.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 25 |
1 files changed, 25 insertions, 0 deletions
| @@ -4,6 +4,7 @@ | |||
| 4 | #include "xs.h" | 4 | #include "xs.h" |
| 5 | #include "xs_io.h" | 5 | #include "xs_io.h" |
| 6 | #include "xs_json.h" | 6 | #include "xs_json.h" |
| 7 | #include "xs_time.h" | ||
| 7 | 8 | ||
| 8 | #include "snac.h" | 9 | #include "snac.h" |
| 9 | 10 | ||
| @@ -22,6 +23,7 @@ int usage(void) | |||
| 22 | printf("deluser {basedir} {uid} Deletes a user\n"); | 23 | printf("deluser {basedir} {uid} Deletes a user\n"); |
| 23 | printf("httpd {basedir} Starts the HTTPD daemon\n"); | 24 | printf("httpd {basedir} Starts the HTTPD daemon\n"); |
| 24 | printf("purge {basedir} Purges old data\n"); | 25 | printf("purge {basedir} Purges old data\n"); |
| 26 | printf("state {basedir} Prints server state\n"); | ||
| 25 | printf("webfinger {basedir} {actor} Queries about an actor (@user@host or actor url)\n"); | 27 | printf("webfinger {basedir} {actor} Queries about an actor (@user@host or actor url)\n"); |
| 26 | printf("queue {basedir} {uid} Processes a user queue\n"); | 28 | printf("queue {basedir} {uid} Processes a user queue\n"); |
| 27 | printf("follow {basedir} {uid} {actor} Follows an actor\n"); | 29 | printf("follow {basedir} {uid} {actor} Follows an actor\n"); |
| @@ -138,6 +140,29 @@ int main(int argc, char *argv[]) | |||
| 138 | return 0; | 140 | return 0; |
| 139 | } | 141 | } |
| 140 | 142 | ||
| 143 | if (strcmp(cmd, "state") == 0) { /** **/ | ||
| 144 | xs *shm_name = NULL; | ||
| 145 | srv_state *p_state = srv_state_op(&shm_name, 1); | ||
| 146 | |||
| 147 | if (p_state == NULL) | ||
| 148 | return 1; | ||
| 149 | |||
| 150 | srv_state ss = *p_state; | ||
| 151 | int n; | ||
| 152 | |||
| 153 | printf("server: %s (%s)\n", xs_dict_get(srv_config, "host"), USER_AGENT); | ||
| 154 | xs *uptime = xs_str_time_diff(time(NULL) - ss.srv_start_time); | ||
| 155 | printf("uptime: %s\n", uptime); | ||
| 156 | printf("job fifo size (cur): %d\n", ss.job_fifo_size); | ||
| 157 | printf("job fifo size (peak): %d\n", ss.peak_job_fifo_size); | ||
| 158 | char *th_states[] = { "stopped", "waiting", "input", "output" }; | ||
| 159 | |||
| 160 | for (n = 0; n < ss.n_threads; n++) | ||
| 161 | printf("thread #%d state: %s\n", n, th_states[ss.th_state[n]]); | ||
| 162 | |||
| 163 | return 0; | ||
| 164 | } | ||
| 165 | |||
| 141 | if ((user = GET_ARGV()) == NULL) | 166 | if ((user = GET_ARGV()) == NULL) |
| 142 | return usage(); | 167 | return usage(); |
| 143 | 168 | ||