10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-21 11:53:30 +01:00

Fixed do_run

This commit is contained in:
Anthony Scemama 2020-04-15 23:59:17 +02:00
parent dcd4e923d4
commit 9fede1e06c

View File

@ -54,6 +54,7 @@ let run ezfio_filename dataserver =
| Unix.Unix_error _ ->
begin
Unix.chdir tmpdir;
Unix.sleep 1;
if Sys.file_exists "PID" then
begin
let pid =
@ -80,7 +81,7 @@ let run ezfio_filename dataserver =
Unix.getpid ()
|> Printf.sprintf "%d\n"
|> output_string oc
;
; close_out oc;
(* Fork a qmc *)
ignore @@
@ -94,6 +95,18 @@ let run ezfio_filename dataserver =
let terminate () =
(* Clean up the temp directory *)
Unix.chdir Qmcchem_config.dev_shm;
Zmq.Context.terminate zmq_context ;
for i=port to port+4
do
let filename =
Printf.sprintf ":%d" i
in
try
Sys.remove filename
with
| _ -> ()
;
done;
let command =
Printf.sprintf "rm -rf -- \"%s\" " tmpdir
in
@ -102,18 +115,6 @@ let run ezfio_filename dataserver =
with
| Unix.Unix_error _ -> print_endline "Unable to remove temporary directory"
;
Zmq.Context.terminate zmq_context ;
for i=port to port+4
do
let filename =
Filename.concat Qmcchem_config.dev_shm (Printf.sprintf ":%d" i)
in
try
Unix.unlink filename
with
| _ -> ()
;
done;
Watchdog.kill ()
in
@ -121,7 +122,7 @@ let run ezfio_filename dataserver =
(* Signal handler to Kill properly all the processes *)
let handler s =
Printf.printf "Forwarder received signal %d... killing\n%!" s;
terminate ();
terminate ()
in
List.iter (fun s -> ignore @@ Sys.signal s (Sys.Signal_handle handler))
[
@ -154,9 +155,6 @@ let run ezfio_filename dataserver =
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port+1);
in
bind_socket "PUB" pub_socket address;
at_exit (fun () ->
Sys.remove (Printf.sprintf "%s:%d" Qmcchem_config.dev_shm (port+1))
);
let sub_socket =
Zmq.Socket.create zmq_context Zmq.Socket.sub
@ -203,9 +201,6 @@ let run ezfio_filename dataserver =
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port+3);
in
bind_socket "XSUB" sub_socket address;
at_exit (fun () ->
Sys.remove (Printf.sprintf "%s:%d" Qmcchem_config.dev_shm (port+3))
);
let pub_socket =
Zmq.Socket.create zmq_context Zmq.Socket.xpub
@ -373,9 +368,6 @@ let run ezfio_filename dataserver =
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port);
in
bind_socket "ROUTER" router_socket address;
at_exit (fun () ->
Sys.remove (Printf.sprintf "%s:%d" Qmcchem_config.dev_shm port)
);
Zmq.Socket.set_receive_high_water_mark router_socket 100000;
Zmq.Socket.set_send_high_water_mark router_socket 100000;
Zmq.Socket.set_immediate router_socket true;
@ -396,9 +388,6 @@ let run ezfio_filename dataserver =
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port+2);
in
bind_socket "PULL" pull_socket address;
at_exit (fun () ->
Sys.remove (Printf.sprintf "%s:%d" Qmcchem_config.dev_shm (port+2))
);
(* Handles messages coming into the ROUTER socket. *)