X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fgraphs%2Ftools%2FuriSetQueue.ml;h=43027580016fe58101457ccc8ae38398ff8f0e8c;hb=97c2d258a5c524eb5c4b85208899d80751a2c82f;hp=12b7e91c0b95bd591c7f45b82349ac800eea8851;hpb=63e86a8e981cda7b7e4438b48ce622b7c222cc42;p=helm.git diff --git a/helm/graphs/tools/uriSetQueue.ml b/helm/graphs/tools/uriSetQueue.ml index 12b7e91c0..430275800 100644 --- a/helm/graphs/tools/uriSetQueue.ml +++ b/helm/graphs/tools/uriSetQueue.ml @@ -29,9 +29,8 @@ Http_common.debug := debug;; open Printf;; +let configuration_file = "/projects/helm/etc/uriSetQueue.conf.xml";; let daemon_name = "Uri Set Queue";; -let default_port = 48082;; -let port_env_var = "URI_SET_QUEUE_PORT";; module OrderedUri: Set.OrderedType with type t = string = struct @@ -77,15 +76,6 @@ let queue_mem item queue = (* mem function over queues *) with Found -> true ;; -let port = - try - int_of_string (Sys.getenv port_env_var) - with - | Not_found -> default_port - | Failure "int_of_string" -> - prerr_endline "Warning: invalid port, reverting to default"; - default_port -in let callback (req: Http_types.request) outchan = try let res = new Http_response.response () in @@ -174,23 +164,25 @@ let callback (req: Http_types.request) outchan = | invalid_request -> debug_print ("Invalid request received"); - Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan); + Http_daemon.respond_error + ~code:(`Status (`Client_error `Bad_request)) outchan); prerr_endline "Request done!\n" with | Http_types.Param_not_found attr_name -> - Http_daemon.respond_error - ~status:(`Client_error `Bad_request) + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) ~body:(sprintf "Parameter '%s' is missing" attr_name) outchan | Failure "int_of_string" -> (* error in converting some paramters *) - Http_daemon.respond_error ~status:(`Client_error `Bad_request) outchan - | Queue_not_found queue_name -> Http_daemon.respond_error - ~status:(`Client_error `Bad_request) + ~code:(`Status (`Client_error `Bad_request)) outchan + | Queue_not_found queue_name -> + Http_daemon.respond_error ~code:(`Status (`Client_error `Bad_request)) ~body:(sprintf "Queue '%d' is not defined" queue_name) outchan in +Helm_registry.load_from configuration_file; +let port = Helm_registry.get_int "uri_set_queue.port" in printf "%s started and listening on port %d\n" daemon_name port; flush stdout; Http_daemon.start' ~port ~mode:`Thread callback;