summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-05-08 09:34:27 +0200
committerGravatar default2023-05-08 09:34:27 +0200
commit920ff76297006968603898e8c60dafd9346dad4b (patch)
treeb7eafa92eae4d2ded367102ebf269926ef676489
parentBackport from xs. (diff)
downloadpenes-snac2-920ff76297006968603898e8c60dafd9346dad4b.tar.gz
penes-snac2-920ff76297006968603898e8c60dafd9346dad4b.tar.xz
penes-snac2-920ff76297006968603898e8c60dafd9346dad4b.zip
Print the total running time at httpd stop.
-rw-r--r--Makefile2
-rw-r--r--httpd.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 7dbd9e7..62beea0 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ html.o: html.c xs.h xs_io.h xs_encdec.h xs_json.h xs_regex.h xs_set.h \
37http.o: http.c xs.h xs_io.h xs_encdec.h xs_openssl.h xs_curl.h xs_time.h \ 37http.o: http.c xs.h xs_io.h xs_encdec.h xs_openssl.h xs_curl.h xs_time.h \
38 xs_json.h snac.h 38 xs_json.h snac.h
39httpd.o: httpd.c xs.h xs_io.h xs_encdec.h xs_json.h xs_socket.h \ 39httpd.o: httpd.c xs.h xs_io.h xs_encdec.h xs_json.h xs_socket.h \
40 xs_httpd.h xs_mime.h snac.h 40 xs_httpd.h xs_mime.h xs_time.h snac.h
41main.o: main.c xs.h xs_io.h xs_encdec.h xs_json.h snac.h 41main.o: main.c xs.h xs_io.h xs_encdec.h xs_json.h snac.h
42mastoapi.o: mastoapi.c xs.h xs_encdec.h xs_openssl.h xs_json.h xs_io.h \ 42mastoapi.o: mastoapi.c xs.h xs_encdec.h xs_openssl.h xs_json.h xs_io.h \
43 xs_time.h xs_glob.h snac.h 43 xs_time.h xs_glob.h snac.h
diff --git a/httpd.c b/httpd.c
index e8223f5..a86142d 100644
--- a/httpd.c
+++ b/httpd.c
@@ -8,6 +8,7 @@
8#include "xs_socket.h" 8#include "xs_socket.h"
9#include "xs_httpd.h" 9#include "xs_httpd.h"
10#include "xs_mime.h" 10#include "xs_mime.h"
11#include "xs_time.h"
11 12
12#include "snac.h" 13#include "snac.h"
13 14
@@ -480,6 +481,7 @@ void httpd(void)
480 pthread_t threads[MAX_THREADS] = {0}; 481 pthread_t threads[MAX_THREADS] = {0};
481 int n_threads = 0; 482 int n_threads = 0;
482 int n; 483 int n;
484 time_t start_time = time(NULL);
483 485
484 address = xs_dict_get(srv_config, "address"); 486 address = xs_dict_get(srv_config, "address");
485 port = xs_number_get(xs_dict_get(srv_config, "port")); 487 port = xs_number_get(xs_dict_get(srv_config, "port"));
@@ -566,5 +568,7 @@ void httpd(void)
566 568
567 sem_close(job_sem); 569 sem_close(job_sem);
568 570
569 srv_log(xs_fmt("httpd stop %s:%d", address, port)); 571 xs *uptime = xs_str_time_diff(time(NULL) - start_time);
572
573 srv_log(xs_fmt("httpd stop %s:%d (run time: %s)", address, port, uptime));
570} 574}