diff --git a/server/Makefile b/server/Makefile index 3dbaf54..e36d5b5 100644 --- a/server/Makefile +++ b/server/Makefile @@ -60,5 +60,8 @@ veryclean: clean thirdpartyclean $(APP).native: $(wildcard *.ml) ocamlbuild -use-ocamlfind -X thirdparty -X scratch $@ +$(APP).p.native: $(wildcard *.ml) + ocamlbuild -use-ocamlfind -X thirdparty -X scratch $@ + run: all ./$(APP).native diff --git a/server/hop_server.ml b/server/hop_server.ml index 41f5e61..ab9a886 100644 --- a/server/hop_server.ml +++ b/server/hop_server.ml @@ -35,6 +35,11 @@ let create_ready_file () = | None -> return () +let console_watcher () = + lwt _ = Lwt_io.read_line Lwt_io.stdin in + Server_control.milestone "Shutdown requested"; + return () + lwt _ = Printf.printf "%s %s, %s\n%s\n%!" App_info.product App_info.version App_info.copyright App_info.licence_blurb; @@ -54,8 +59,9 @@ lwt _ = lwt () = Server_control.run_until "AMQP ready" in lwt () = Server_control.run_until "HTTP ready" in lwt () = Server_control.run_until "Hop ready" in + ignore (console_watcher ()); if Server_control.is_running () then (lwt () = create_ready_file () in Server_control.milestone "Server initialized"; - Server_control.run_forever ()) + Server_control.run_until "Shutdown requested") else return ()