mirror of
https://gitlab.com/scemama/qmcchem.git
synced 2024-11-19 04:22:21 +01:00
Fixed do_run
This commit is contained in:
parent
dcd4e923d4
commit
9fede1e06c
@ -54,6 +54,7 @@ let run ezfio_filename dataserver =
|
|||||||
| Unix.Unix_error _ ->
|
| Unix.Unix_error _ ->
|
||||||
begin
|
begin
|
||||||
Unix.chdir tmpdir;
|
Unix.chdir tmpdir;
|
||||||
|
Unix.sleep 1;
|
||||||
if Sys.file_exists "PID" then
|
if Sys.file_exists "PID" then
|
||||||
begin
|
begin
|
||||||
let pid =
|
let pid =
|
||||||
@ -80,7 +81,7 @@ let run ezfio_filename dataserver =
|
|||||||
Unix.getpid ()
|
Unix.getpid ()
|
||||||
|> Printf.sprintf "%d\n"
|
|> Printf.sprintf "%d\n"
|
||||||
|> output_string oc
|
|> output_string oc
|
||||||
;
|
; close_out oc;
|
||||||
|
|
||||||
(* Fork a qmc *)
|
(* Fork a qmc *)
|
||||||
ignore @@
|
ignore @@
|
||||||
@ -94,6 +95,18 @@ let run ezfio_filename dataserver =
|
|||||||
let terminate () =
|
let terminate () =
|
||||||
(* Clean up the temp directory *)
|
(* Clean up the temp directory *)
|
||||||
Unix.chdir Qmcchem_config.dev_shm;
|
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 =
|
let command =
|
||||||
Printf.sprintf "rm -rf -- \"%s\" " tmpdir
|
Printf.sprintf "rm -rf -- \"%s\" " tmpdir
|
||||||
in
|
in
|
||||||
@ -102,18 +115,6 @@ let run ezfio_filename dataserver =
|
|||||||
with
|
with
|
||||||
| Unix.Unix_error _ -> print_endline "Unable to remove temporary directory"
|
| 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 ()
|
Watchdog.kill ()
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ let run ezfio_filename dataserver =
|
|||||||
(* Signal handler to Kill properly all the processes *)
|
(* Signal handler to Kill properly all the processes *)
|
||||||
let handler s =
|
let handler s =
|
||||||
Printf.printf "Forwarder received signal %d... killing\n%!" s;
|
Printf.printf "Forwarder received signal %d... killing\n%!" s;
|
||||||
terminate ();
|
terminate ()
|
||||||
in
|
in
|
||||||
List.iter (fun s -> ignore @@ Sys.signal s (Sys.Signal_handle handler))
|
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);
|
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port+1);
|
||||||
in
|
in
|
||||||
bind_socket "PUB" pub_socket address;
|
bind_socket "PUB" pub_socket address;
|
||||||
at_exit (fun () ->
|
|
||||||
Sys.remove (Printf.sprintf "%s:%d" Qmcchem_config.dev_shm (port+1))
|
|
||||||
);
|
|
||||||
|
|
||||||
let sub_socket =
|
let sub_socket =
|
||||||
Zmq.Socket.create zmq_context Zmq.Socket.sub
|
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);
|
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port+3);
|
||||||
in
|
in
|
||||||
bind_socket "XSUB" sub_socket address;
|
bind_socket "XSUB" sub_socket address;
|
||||||
at_exit (fun () ->
|
|
||||||
Sys.remove (Printf.sprintf "%s:%d" Qmcchem_config.dev_shm (port+3))
|
|
||||||
);
|
|
||||||
|
|
||||||
let pub_socket =
|
let pub_socket =
|
||||||
Zmq.Socket.create zmq_context Zmq.Socket.xpub
|
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);
|
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port);
|
||||||
in
|
in
|
||||||
bind_socket "ROUTER" router_socket address;
|
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_receive_high_water_mark router_socket 100000;
|
||||||
Zmq.Socket.set_send_high_water_mark router_socket 100000;
|
Zmq.Socket.set_send_high_water_mark router_socket 100000;
|
||||||
Zmq.Socket.set_immediate router_socket true;
|
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);
|
Printf.sprintf "ipc://%s:%d" Qmcchem_config.dev_shm (port+2);
|
||||||
in
|
in
|
||||||
bind_socket "PULL" pull_socket address;
|
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. *)
|
(* Handles messages coming into the ROUTER socket. *)
|
||||||
|
Loading…
Reference in New Issue
Block a user