mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-21 12:55:04 +00:00
The server creates a pidfile inside the base directory.
This commit is contained in:
parent
0858f57d8a
commit
876c892960
1 changed files with 14 additions and 0 deletions
14
httpd.c
14
httpd.c
|
@ -774,6 +774,7 @@ void httpd(void)
|
||||||
xs *sem_name = NULL;
|
xs *sem_name = NULL;
|
||||||
xs *shm_name = NULL;
|
xs *shm_name = NULL;
|
||||||
sem_t anon_job_sem;
|
sem_t anon_job_sem;
|
||||||
|
xs *pidfile = xs_fmt("%s/server.pid", srv_basedir);
|
||||||
|
|
||||||
address = xs_dict_get(srv_config, "address");
|
address = xs_dict_get(srv_config, "address");
|
||||||
|
|
||||||
|
@ -809,6 +810,17 @@ void httpd(void)
|
||||||
srv_log(xs_fmt("httpd%s start %s %s", p_state->use_fcgi ? " (FastCGI)" : "",
|
srv_log(xs_fmt("httpd%s start %s %s", p_state->use_fcgi ? " (FastCGI)" : "",
|
||||||
full_address, USER_AGENT));
|
full_address, USER_AGENT));
|
||||||
|
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
if ((f = fopen(pidfile, "w")) != NULL) {
|
||||||
|
fprintf(f, "%d\n", getpid());
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
srv_log(xs_fmt("Cannot create %s: %s", pidfile, strerror(errno)));
|
||||||
|
}
|
||||||
|
|
||||||
/* show the number of usable file descriptors */
|
/* show the number of usable file descriptors */
|
||||||
struct rlimit r;
|
struct rlimit r;
|
||||||
getrlimit(RLIMIT_NOFILE, &r);
|
getrlimit(RLIMIT_NOFILE, &r);
|
||||||
|
@ -894,4 +906,6 @@ void httpd(void)
|
||||||
srv_log(xs_fmt("httpd%s stop %s (run time: %s)",
|
srv_log(xs_fmt("httpd%s stop %s (run time: %s)",
|
||||||
p_state->use_fcgi ? " (FastCGI)" : "",
|
p_state->use_fcgi ? " (FastCGI)" : "",
|
||||||
full_address, uptime));
|
full_address, uptime));
|
||||||
|
|
||||||
|
unlink(pidfile);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue