(* debugging settings *)
let debug = false;;
-let debug_level = `Debug;;
+let debug_level = `Notice;;
let debug_print s = if debug then prerr_endline s;;
Http_common.debug := false;;
let logfile = Some "uwobo.log";; (* relative to execution dir *)
(* (2) stylesheets list *)
let styles = new Uwobo_styles.styles in
(* (3) clean up actions *)
+ let last_process = ref true in
let die_nice () = (** at_exit callback *)
- syslogger#log `Notice (sprintf "%s is terminating, bye!" daemon_name);
- syslogger#disable;
- close_out logger_outchan
+ if !last_process then begin
+ syslogger#log `Notice (sprintf "%s is terminating, bye!" daemon_name);
+ syslogger#disable;
+ close_out logger_outchan
+ end
in
+ at_exit die_nice;
syslogger#log `Notice
(sprintf "%s started and listening on port %d" daemon_name port);
syslogger#log `Notice (sprintf "current directory is %s" (Sys.getcwd ()));
let (cmd_pipe_exit, cmd_pipe_entrance) = Unix.pipe () in
let (res_pipe_exit, res_pipe_entrance) = Unix.pipe () in
match Unix.fork () with
- | child when child > 0 -> (* (5) parent: listen on cmd pipe for updates *)
+ | child when child > 0 -> (* (4) parent: listen on cmd pipe for updates *)
let stop_http_daemon () = (* kill child *)
debug_print (sprintf "Grandparent: killing pid %d" child);
Unix.kill child Sys.sigterm; (* kill child ... *)
ignore (Unix.waitpid [] child); (* ... and its zombie *)
debug_print "Grandparent: murder completed!!!"
in
- at_exit die_nice;
Unix.close cmd_pipe_entrance;
Unix.close res_pipe_exit;
let cmd_pipe = Unix.in_channel_of_descr cmd_pipe_exit in
with Restart_HTTP_daemon ->
close_in cmd_pipe; (* these calls close also fds *)
close_out res_pipe;)
- | 0 -> (* (6) child: serve http requests *)
+ | 0 -> (* (5) child: serve http requests *)
Unix.close cmd_pipe_exit;
Unix.close res_pipe_entrance;
+ last_process := false;
let cmd_pipe = Unix.out_channel_of_descr cmd_pipe_entrance in
let res_pipe = Unix.in_channel_of_descr res_pipe_exit in
debug_print "Starting HTTP daemon ...";