From 52d40595f2cc59fb58a9c544041fccc59f223a58 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 13 May 2005 09:16:51 +0000 Subject: [PATCH] - ported to new ocaml-http API - uses Arg for cmdline parsing --- helm/http_getter/main.ml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/helm/http_getter/main.ml b/helm/http_getter/main.ml index 640584e63..5f7e8cd93 100644 --- a/helm/http_getter/main.ml +++ b/helm/http_getter/main.ml @@ -347,25 +347,33 @@ let callback (req: Http_types.request) outchan = 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 -- 2.39.2