From 750e15351055085126b3719e140f96f5f9d41d95 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 15 Apr 2004 13:35:53 +0000 Subject: [PATCH] - better pretty printing of exceptions (added red color) - added "-update" command line parameter for batch updating --- helm/http_getter/main.ml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/helm/http_getter/main.ml b/helm/http_getter/main.ml index 974d029e5..699c685bb 100644 --- a/helm/http_getter/main.ml +++ b/helm/http_getter/main.ml @@ -115,9 +115,9 @@ let mk_return_fun pp_fun contype msg outchan = Http_daemon.respond ~body:(pp_fun msg) ~headers:["Content-Type", contype] outchan let pp_error s = - sprintf "Http Getter error: %s" s + sprintf "Http Getter error: %s" s let pp_internal_error s = - sprintf "Http Getter Internal error: %s" s + sprintf "Http Getter Internal error: %s" s let pp_msg s = sprintf "%s" s let null_pp s = s let return_html_error = mk_return_fun pp_error "text/html" @@ -342,13 +342,20 @@ let main () = Http_getter_env.reload (); print_string (Http_getter_env.env_to_string ()); flush stdout; - at_exit Http_getter.close_maps; - Sys.catch_break true; - try - Http_daemon.start' ~mode:`Thread - ~timeout:(Some 600) ~port:(Helm_registry.get_int "getter.port") - callback - with Sys.Break -> () (* 'close_maps' already registered with 'at_exit' *) + let batch_update = + try Sys.argv.(1) = "-update" with Invalid_argument _ -> false + in + 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; + try + Http_daemon.start' ~mode:`Thread + ~timeout:(Some 600) ~port:(Helm_registry.get_int "getter.port") + callback + with Sys.Break -> () (* 'close_maps' already registered with 'at_exit' *) + end let _ = main () -- 2.39.2