tweak for fcgi
[camlunity.git] / main.ml
blob5583bac00bfca8b0fa9a3aad9191e25721531029
2 open Prelude
4 let fcgi_port = ref 0
6 let () =
7 let args = Arg.align
9 "-fcgi", Arg.Set_int fcgi_port, "<port> run as fcgi";
12 Arg.parse args (fail "Unknown argument %s") "Allowed options:"
14 let fcgi_port = !fcgi_port
16 let run_cgi () =
17 Netcgi_cgi.run
18 ~output_type:(`Direct "")
19 (Request.main true)
21 let run_fcgi () =
22 Netcgi_fcgi.run
23 ~sockaddr:(Unix.ADDR_INET (Unix.inet_addr_loopback,fcgi_port))
24 ~output_type:(`Direct "")
25 (Request.main false)
27 let main () =
28 match fcgi_port with
29 | 0 -> run_cgi ()
30 | _ -> run_fcgi ()
32 let () =
33 Printexc.record_backtrace true;
34 try
35 main ()
36 with
37 e ->
38 print_endline (Printexc.to_string e);
39 print_endline (Printexc.get_backtrace ())