Node: properly report RPC port already in use, fixes #69
This commit is contained in:
parent
89f9d9aa5f
commit
4109adfd77
@ -21,6 +21,7 @@ let genesis : State.Net.genesis = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type error += Non_private_sandbox of P2p_types.addr
|
type error += Non_private_sandbox of P2p_types.addr
|
||||||
|
type error += RPC_Port_already_in_use of P2p_types.addr
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
register_error_kind
|
register_error_kind
|
||||||
@ -37,7 +38,21 @@ let () =
|
|||||||
end
|
end
|
||||||
Data_encoding.(obj1 (req "addr" P2p_types.addr_encoding))
|
Data_encoding.(obj1 (req "addr" P2p_types.addr_encoding))
|
||||||
(function Non_private_sandbox addr -> Some addr | _ -> None)
|
(function Non_private_sandbox addr -> Some addr | _ -> None)
|
||||||
(fun addr -> Non_private_sandbox addr)
|
(fun addr -> Non_private_sandbox addr);
|
||||||
|
register_error_kind
|
||||||
|
`Permanent
|
||||||
|
~id:"main.run.port_already_in_use"
|
||||||
|
~title:"Cannot start sode: RPC port already in use"
|
||||||
|
~description:"An other tezos node is probably running on the same RPC port."
|
||||||
|
~pp:begin fun ppf addr ->
|
||||||
|
Format.fprintf ppf
|
||||||
|
"An other tezos node is probably running on port (%a). \
|
||||||
|
Please choose another RPC port."
|
||||||
|
Ipaddr.V6.pp_hum addr
|
||||||
|
end
|
||||||
|
Data_encoding.(obj1 (req "addr" P2p_types.addr_encoding))
|
||||||
|
(function RPC_Port_already_in_use addr -> Some addr | _ -> None)
|
||||||
|
(fun addr -> RPC_Port_already_in_use addr)
|
||||||
|
|
||||||
let (//) = Filename.concat
|
let (//) = Filename.concat
|
||||||
|
|
||||||
@ -186,11 +201,18 @@ let init_rpc (rpc_config: Node_config_file.rpc) node =
|
|||||||
"Starting the RPC server listening on port %d%s."
|
"Starting the RPC server listening on port %d%s."
|
||||||
port
|
port
|
||||||
(if rpc_config.tls = None then "" else " (TLS enabled)") >>= fun () ->
|
(if rpc_config.tls = None then "" else " (TLS enabled)") >>= fun () ->
|
||||||
RPC_server.launch ~host mode dir
|
Lwt.catch
|
||||||
~media_types:Media_type.all_media_types
|
(fun () ->
|
||||||
~cors:{ allowed_origins = rpc_config.cors_origins ;
|
RPC_server.launch ~host mode dir
|
||||||
allowed_headers = rpc_config.cors_headers } >>= fun server ->
|
~media_types:Media_type.all_media_types
|
||||||
return (Some server)
|
~cors:{ allowed_origins = rpc_config.cors_origins ;
|
||||||
|
allowed_headers = rpc_config.cors_headers } >>= fun server ->
|
||||||
|
return (Some server))
|
||||||
|
(function
|
||||||
|
|Unix.Unix_error(Unix.EADDRINUSE, "bind","") ->
|
||||||
|
fail (RPC_Port_already_in_use addr)
|
||||||
|
| exn -> Lwt.return (error_exn exn)
|
||||||
|
)
|
||||||
|
|
||||||
let init_signal () =
|
let init_signal () =
|
||||||
let handler name id = try
|
let handler name id = try
|
||||||
|
Loading…
Reference in New Issue
Block a user