log_failure msg;
return_html_error ("uncaught_exception", msg) msg outchan)
- (* Main *)
+let batch_update = ref false
+let args = [
+ ("-update",
+ Arg.Unit (fun () -> batch_update := true),
+ "\tupdate maps and exit");
+]
+
+ (* Main *)
let main () =
+ Arg.parse args (fun _->()) "http_getter honors the following options:\n";
Helm_registry.load_from configuration_file;
Http_getter.init ();
print_string (Http_getter_env.env_to_string ());
flush stdout;
- let batch_update =
- try Sys.argv.(1) = "-update" with Invalid_argument _ -> false
- in
- if batch_update then (* batch mode: performs update and exit *)
+ if !batch_update then (* batch mode: performs update and exit *)
Http_getter.update ~logger:Http_getter.stdout_logger ()
else begin (* daemon mode: start http daemon *)
at_exit Http_getter.close_maps;
Sys.catch_break true;
+ let d_spec = Http_daemon.daemon_spec
+ ~mode:`Thread ~timeout:(Some 600)
+ ~port:(Lazy.force Http_getter_env.port)
+ ~callback:callback ()
+ in
try
- Http_daemon.start' ~mode:`Thread
- ~timeout:(Some 600) ~port:(Lazy.force Http_getter_env.port)
- callback
+ Http_daemon.main d_spec
with Sys.Break -> () (* 'close_maps' already registered with 'at_exit' *)
end