summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-11-17 10:21:15 +0100
committerGravatar default2024-11-17 10:21:15 +0100
commit876c892960c7e45daf62369ea58f47ad42bfb98e (patch)
tree144327996158748e33c9b8b9f1edd1b0776c8e1c
parentUpdated TODO. (diff)
downloadpenes-snac2-876c892960c7e45daf62369ea58f47ad42bfb98e.tar.gz
penes-snac2-876c892960c7e45daf62369ea58f47ad42bfb98e.tar.xz
penes-snac2-876c892960c7e45daf62369ea58f47ad42bfb98e.zip
The server creates a pidfile inside the base directory.
Diffstat (limited to '')
-rw-r--r--httpd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/httpd.c b/httpd.c
index 1613e1f..81d2f9e 100644
--- a/httpd.c
+++ b/httpd.c
@@ -774,6 +774,7 @@ void httpd(void)
774 xs *sem_name = NULL; 774 xs *sem_name = NULL;
775 xs *shm_name = NULL; 775 xs *shm_name = NULL;
776 sem_t anon_job_sem; 776 sem_t anon_job_sem;
777 xs *pidfile = xs_fmt("%s/server.pid", srv_basedir);
777 778
778 address = xs_dict_get(srv_config, "address"); 779 address = xs_dict_get(srv_config, "address");
779 780
@@ -809,6 +810,17 @@ void httpd(void)
809 srv_log(xs_fmt("httpd%s start %s %s", p_state->use_fcgi ? " (FastCGI)" : "", 810 srv_log(xs_fmt("httpd%s start %s %s", p_state->use_fcgi ? " (FastCGI)" : "",
810 full_address, USER_AGENT)); 811 full_address, USER_AGENT));
811 812
813 {
814 FILE *f;
815
816 if ((f = fopen(pidfile, "w")) != NULL) {
817 fprintf(f, "%d\n", getpid());
818 fclose(f);
819 }
820 else
821 srv_log(xs_fmt("Cannot create %s: %s", pidfile, strerror(errno)));
822 }
823
812 /* show the number of usable file descriptors */ 824 /* show the number of usable file descriptors */
813 struct rlimit r; 825 struct rlimit r;
814 getrlimit(RLIMIT_NOFILE, &r); 826 getrlimit(RLIMIT_NOFILE, &r);
@@ -894,4 +906,6 @@ void httpd(void)
894 srv_log(xs_fmt("httpd%s stop %s (run time: %s)", 906 srv_log(xs_fmt("httpd%s stop %s (run time: %s)",
895 p_state->use_fcgi ? " (FastCGI)" : "", 907 p_state->use_fcgi ? " (FastCGI)" : "",
896 full_address, uptime)); 908 full_address, uptime));
909
910 unlink(pidfile);
897} 911}