[LON-CAPA-cvs] cvs: modules /gerd lonhttpd
www
lon-capa-cvs@mail.lon-capa.org
Tue, 29 Oct 2002 19:37:32 -0000
www Tue Oct 29 14:37:32 2002 EDT
Modified files:
/modules/gerd lonhttpd
Log:
Forks, dissociates, writes PID.
Index: modules/gerd/lonhttpd
diff -u modules/gerd/lonhttpd:1.2 modules/gerd/lonhttpd:1.3
--- modules/gerd/lonhttpd:1.2 Tue Oct 29 14:23:02 2002
+++ modules/gerd/lonhttpd Tue Oct 29 14:37:32 2002
@@ -1,15 +1,26 @@
#!/usr/bin/perl
+# The LearningOnline Network with CAPA
+# lonhttpd server (port 8080)
+# based on
# TinyHTTPD - a minimum-functional HTTP server written in -*- Perl -*-
# -ot.0894
-# $Id: lonhttpd,v 1.2 2002/10/29 19:23:02 www Exp $
+# $Id: lonhttpd,v 1.3 2002/10/29 19:37:32 www Exp $
# Currently supported: HTTP 1.0/1.1 GET and POST queries
# File types of .html and .gif
-$ENV{'SERVER_SOFTWARE'}="TinyHTTPD $Revision: 1.2 $ -ot.0894 (LON-CAPA)";
+$ENV{'SERVER_SOFTWARE'}="TinyHTTPD $Revision: 1.3 $ -ot.0894 (LON-CAPA)";
-use POSIX qw(:sys_wait_h);
+use POSIX;
+
+$pid=fork;
+exit if $pid;
+die "Could not fork: $!" unless defined($pid);
+POSIX::setsid() or die "Can't start new session: $!";
+open (PIDSAVE,">/home/httpd/perl/logs/lonhttpd.pid");
+print PIDSAVE "$$\n";
+close(PIDSAVE);
sub REAPER {
1 until (-1==waitpid(-1,WNOHANG));
@@ -51,7 +62,7 @@
socket(S, $PF_INET, $SOCK_STREAM, $IPPROTO_TCP) || die "socket: $!";
bind(S, $this) || die "bind: $!";
listen(S, 5) || die "listen: $!";
-open(LOG,">> httpd.log");
+open(LOG,">/home/httpd/perl/logs/lonhttpd.log");
select(LOG); $|=1;
open(STDERR, ">&LOG") || die "dup2 log->stderr";