Daemon: await_bootstrapped_node
now retries on Connection_failed
This allows the baker/endorser/accuser to wait a litlle bit for the node to initialize itself and to open its RPC port. By default, the deamon retries 6 times with a total waiting time around 20 seconds, before to fail.
This commit is contained in:
parent
32a1d2647c
commit
b7c2546e5b
@ -23,11 +23,33 @@
|
||||
(* *)
|
||||
(*****************************************************************************)
|
||||
|
||||
let rec retry (cctxt: #Proto_alpha.full) ~delay ~tries f x =
|
||||
f x >>= function
|
||||
| Ok _ as r -> Lwt.return r
|
||||
| Error (RPC_client.Request_failed
|
||||
{ error = Connection_failed _ ; _ } :: _) as err
|
||||
when tries > 0 -> begin
|
||||
cctxt#message
|
||||
"Connection refused, retrying in %.2f seconds..."
|
||||
delay >>= fun () ->
|
||||
Lwt.pick
|
||||
[ (Lwt_unix.sleep delay >|= fun () -> `Continue) ;
|
||||
(Lwt_exit.termination_thread >|= fun _ -> `Killed) ;
|
||||
] >>= function
|
||||
| `Killed ->
|
||||
Lwt.return err
|
||||
| `Continue ->
|
||||
retry cctxt ~delay:(delay *. 1.5) ~tries:(tries - 1) f x
|
||||
end
|
||||
| Error _ as err ->
|
||||
Lwt.return err
|
||||
|
||||
let await_bootstrapped_node (cctxt: #Proto_alpha.full) =
|
||||
(* Waiting for the node to be synchronized *)
|
||||
cctxt#message "Waiting for the node to be synchronized with its \
|
||||
peers..." >>= fun () ->
|
||||
Shell_services.Monitor.bootstrapped cctxt >>=? fun _ ->
|
||||
retry cctxt ~tries:5 ~delay:1.
|
||||
Shell_services.Monitor.bootstrapped cctxt >>=? fun _ ->
|
||||
cctxt#message "Node synchronized." >>= fun () ->
|
||||
return_unit
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
tezos-client-alpha
|
||||
tezos-client-commands
|
||||
tezos-storage
|
||||
tezos-rpc-http
|
||||
tezos-rpc)
|
||||
(library_flags (:standard -linkall))
|
||||
(modules (:standard \
|
||||
@ -22,7 +23,8 @@
|
||||
-open Tezos_client_alpha
|
||||
-open Tezos_client_commands
|
||||
-open Tezos_storage
|
||||
-open Tezos_rpc)))
|
||||
-open Tezos_rpc
|
||||
-open Tezos_rpc_http)))
|
||||
|
||||
(library
|
||||
(name tezos_baking_alpha_commands)
|
||||
|
Loading…
Reference in New Issue
Block a user