X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fhttp_getter%2Fmain.ml;h=5f7e8cd93582e94a90dd9bf27619266031451ab8;hb=acf29bdbdcdc6ad8c2d9d27e8a47500981b605cd;hp=640584e63a9729e2d03941162c5633039ac2c7a5;hpb=07b89f0a77a8099cda7b53b4babdf9511966d8fd;p=helm.git 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