summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--httpd.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/httpd.c b/httpd.c
index d401d7d..0d52d23 100644
--- a/httpd.c
+++ b/httpd.c
@@ -30,6 +30,8 @@ int use_fcgi = 0;
30 30
31int srv_running = 0; 31int srv_running = 0;
32 32
33time_t srv_start_time = 0;
34
33/* nodeinfo 2.0 template */ 35/* nodeinfo 2.0 template */
34const char *nodeinfo_2_0_template = "" 36const char *nodeinfo_2_0_template = ""
35 "{\"version\":\"2.0\"," 37 "{\"version\":\"2.0\","
@@ -209,6 +211,15 @@ int server_get_handler(xs_dict *req, const char *q_path,
209 *body = xs_str_new("User-agent: *\n" 211 *body = xs_str_new("User-agent: *\n"
210 "Disallow: /\n"); 212 "Disallow: /\n");
211 } 213 }
214 else
215 if (strcmp(q_path, "/status.txt") == 0) {
216 status = 200;
217 *ctype = "text/plain";
218 *body = xs_str_new("UP\n");
219
220 xs *uptime = xs_str_time_diff(time(NULL) - srv_start_time);
221 srv_log(xs_fmt("status: uptime: %s", uptime));
222 }
212 223
213 if (status != 0) 224 if (status != 0)
214 srv_debug(1, xs_fmt("server_get_handler serving '%s' %d", q_path, status)); 225 srv_debug(1, xs_fmt("server_get_handler serving '%s' %d", q_path, status));
@@ -591,10 +602,11 @@ void httpd(void)
591 pthread_t threads[MAX_THREADS] = {0}; 602 pthread_t threads[MAX_THREADS] = {0};
592 int n_threads = 0; 603 int n_threads = 0;
593 int n; 604 int n;
594 time_t start_time = time(NULL);
595 char sem_name[24]; 605 char sem_name[24];
596 sem_t anon_job_sem; 606 sem_t anon_job_sem;
597 607
608 srv_start_time = time(NULL);
609
598 use_fcgi = xs_type(xs_dict_get(srv_config, "fastcgi")) == XSTYPE_TRUE; 610 use_fcgi = xs_type(xs_dict_get(srv_config, "fastcgi")) == XSTYPE_TRUE;
599 611
600 address = xs_dict_get(srv_config, "address"); 612 address = xs_dict_get(srv_config, "address");
@@ -697,7 +709,7 @@ void httpd(void)
697 sem_close(job_sem); 709 sem_close(job_sem);
698 sem_unlink(sem_name); 710 sem_unlink(sem_name);
699 711
700 xs *uptime = xs_str_time_diff(time(NULL) - start_time); 712 xs *uptime = xs_str_time_diff(time(NULL) - srv_start_time);
701 713
702 srv_log(xs_fmt("httpd%s stop %s:%s (run time: %s)", use_fcgi ? " (FastCGI)" : "", 714 srv_log(xs_fmt("httpd%s stop %s:%s (run time: %s)", use_fcgi ? " (FastCGI)" : "",
703 address, port, uptime)); 715 address, port, uptime));