mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
New page status.txt.
It just return an empty page as a query, but some status logging is done.
This commit is contained in:
parent
d9ca841cc9
commit
e8b94c1773
1 changed files with 14 additions and 2 deletions
16
httpd.c
16
httpd.c
|
@ -30,6 +30,8 @@ int use_fcgi = 0;
|
||||||
|
|
||||||
int srv_running = 0;
|
int srv_running = 0;
|
||||||
|
|
||||||
|
time_t srv_start_time = 0;
|
||||||
|
|
||||||
/* nodeinfo 2.0 template */
|
/* nodeinfo 2.0 template */
|
||||||
const char *nodeinfo_2_0_template = ""
|
const char *nodeinfo_2_0_template = ""
|
||||||
"{\"version\":\"2.0\","
|
"{\"version\":\"2.0\","
|
||||||
|
@ -209,6 +211,15 @@ int server_get_handler(xs_dict *req, const char *q_path,
|
||||||
*body = xs_str_new("User-agent: *\n"
|
*body = xs_str_new("User-agent: *\n"
|
||||||
"Disallow: /\n");
|
"Disallow: /\n");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (strcmp(q_path, "/status.txt") == 0) {
|
||||||
|
status = 200;
|
||||||
|
*ctype = "text/plain";
|
||||||
|
*body = xs_str_new("UP\n");
|
||||||
|
|
||||||
|
xs *uptime = xs_str_time_diff(time(NULL) - srv_start_time);
|
||||||
|
srv_log(xs_fmt("status: uptime: %s", uptime));
|
||||||
|
}
|
||||||
|
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
srv_debug(1, xs_fmt("server_get_handler serving '%s' %d", q_path, status));
|
srv_debug(1, xs_fmt("server_get_handler serving '%s' %d", q_path, status));
|
||||||
|
@ -591,10 +602,11 @@ void httpd(void)
|
||||||
pthread_t threads[MAX_THREADS] = {0};
|
pthread_t threads[MAX_THREADS] = {0};
|
||||||
int n_threads = 0;
|
int n_threads = 0;
|
||||||
int n;
|
int n;
|
||||||
time_t start_time = time(NULL);
|
|
||||||
char sem_name[24];
|
char sem_name[24];
|
||||||
sem_t anon_job_sem;
|
sem_t anon_job_sem;
|
||||||
|
|
||||||
|
srv_start_time = time(NULL);
|
||||||
|
|
||||||
use_fcgi = xs_type(xs_dict_get(srv_config, "fastcgi")) == XSTYPE_TRUE;
|
use_fcgi = xs_type(xs_dict_get(srv_config, "fastcgi")) == XSTYPE_TRUE;
|
||||||
|
|
||||||
address = xs_dict_get(srv_config, "address");
|
address = xs_dict_get(srv_config, "address");
|
||||||
|
@ -697,7 +709,7 @@ void httpd(void)
|
||||||
sem_close(job_sem);
|
sem_close(job_sem);
|
||||||
sem_unlink(sem_name);
|
sem_unlink(sem_name);
|
||||||
|
|
||||||
xs *uptime = xs_str_time_diff(time(NULL) - start_time);
|
xs *uptime = xs_str_time_diff(time(NULL) - srv_start_time);
|
||||||
|
|
||||||
srv_log(xs_fmt("httpd%s stop %s:%s (run time: %s)", use_fcgi ? " (FastCGI)" : "",
|
srv_log(xs_fmt("httpd%s stop %s:%s (run time: %s)", use_fcgi ? " (FastCGI)" : "",
|
||||||
address, port, uptime));
|
address, port, uptime));
|
||||||
|
|
Loading…
Reference in a new issue