2012-03-07 18:23:41 +00:00
|
|
|
(* Copyright 2012 Tony Garnock-Jones <tonygarnockjones@gmail.com>. *)
|
|
|
|
|
2012-05-01 21:36:38 +00:00
|
|
|
(* This file is part of Hop. *)
|
2012-03-07 18:23:41 +00:00
|
|
|
|
2012-05-01 21:36:38 +00:00
|
|
|
(* Hop is free software: you can redistribute it and/or modify it *)
|
2012-03-07 18:23:41 +00:00
|
|
|
(* under the terms of the GNU General Public License as published by the *)
|
|
|
|
(* Free Software Foundation, either version 3 of the License, or (at your *)
|
|
|
|
(* option) any later version. *)
|
|
|
|
|
2012-05-01 21:36:38 +00:00
|
|
|
(* Hop is distributed in the hope that it will be useful, but *)
|
2012-03-07 18:23:41 +00:00
|
|
|
(* WITHOUT ANY WARRANTY; without even the implied warranty of *)
|
|
|
|
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *)
|
|
|
|
(* General Public License for more details. *)
|
|
|
|
|
|
|
|
(* You should have received a copy of the GNU General Public License *)
|
2012-05-01 21:36:38 +00:00
|
|
|
(* along with Hop. If not, see <http://www.gnu.org/licenses/>. *)
|
2012-03-07 18:23:41 +00:00
|
|
|
|
2012-01-08 19:48:07 +00:00
|
|
|
let hook_log () =
|
|
|
|
let old_hook = !Log.hook in
|
|
|
|
let new_hook label body =
|
|
|
|
ignore (Node.post "system.log" (Sexp.Str label) body (Sexp.Str ""));
|
|
|
|
old_hook label body
|
|
|
|
in
|
|
|
|
Log.hook := new_hook
|
|
|
|
|
2012-05-01 19:37:39 +00:00
|
|
|
let create_ready_file () =
|
|
|
|
match Config.get "ready-file" with
|
|
|
|
| Some ready_file_path ->
|
|
|
|
Log.info "Creating ready file" [Sexp.Str ready_file_path];
|
|
|
|
close_out (open_out ready_file_path)
|
|
|
|
| None ->
|
|
|
|
()
|
|
|
|
|
2012-01-08 17:41:04 +00:00
|
|
|
let _ =
|
2012-03-07 18:23:41 +00:00
|
|
|
Printf.printf "%s %s, %s\n%s\n%!"
|
|
|
|
App_info.product App_info.version App_info.copyright App_info.licence_blurb;
|
2012-01-08 19:02:18 +00:00
|
|
|
Sys.set_signal Sys.sigpipe Sys.Signal_ignore;
|
2012-01-08 17:41:04 +00:00
|
|
|
Uuid.init ();
|
2012-05-01 19:37:39 +00:00
|
|
|
Config.init ();
|
2012-01-08 17:41:04 +00:00
|
|
|
Factory.init ();
|
|
|
|
Queuenode.init ();
|
2012-03-05 21:56:43 +00:00
|
|
|
Fanoutnode.init ();
|
2012-03-04 17:12:20 +00:00
|
|
|
Directnode.init ();
|
2012-03-06 22:05:57 +00:00
|
|
|
Meta.init ();
|
2012-01-08 19:48:07 +00:00
|
|
|
hook_log ();
|
2012-03-04 18:03:38 +00:00
|
|
|
Amqp_relay.init ();
|
2012-04-28 21:17:04 +00:00
|
|
|
Ui_main.init ();
|
2012-04-29 20:34:52 +00:00
|
|
|
Ui_relay.init ();
|
2012-05-01 19:37:39 +00:00
|
|
|
Relay.init ();
|
|
|
|
Server_control.run_until "AMQP ready";
|
|
|
|
Server_control.run_until "HTTP ready";
|
|
|
|
Server_control.run_until "Hop ready";
|
|
|
|
if Server_control.is_running ()
|
|
|
|
then (create_ready_file ();
|
2012-05-02 15:11:38 +00:00
|
|
|
Server_control.milestone "Server initialized";
|
2012-05-01 19:37:39 +00:00
|
|
|
Server_control.run_forever ())
|
|
|
|
else ()
|