Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/grisp_connect.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
{ws_request_timeout, 5_000},
{ws_ping_timeout, 60_000},
{ws_max_retries, infinity},
{reboot_cb, undefined},
{allow_expired_certs, false},
% Must be writable and match the cacertfile in ssl_dist_opts.rel
{board_certificate, "/etc/board.pem"},
Expand Down
2 changes: 1 addition & 1 deletion src/grisp_connect_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ handle_common(cast, {notify, _Method, _Type, _Params}, _State, _Data) ->
% We ignore notifications sent while disconnected
keep_state_and_data;
handle_common(info, reboot, _, _) ->
init:stop(),
grisp_connect_utils:reboot(),
keep_state_and_data;
handle_common(info, {'EXIT', Conn, Reason}, _State, Data = #data{conn = Conn}) ->
RealReason = case Reason of
Expand Down
14 changes: 14 additions & 0 deletions src/grisp_connect_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

% API functions
-export([using_grisp_netman/0]).
-export([reboot/0]).
-export([retry_delay/1]).
-export([check_inet_ipv4/0]).

Expand All @@ -15,6 +16,19 @@ using_grisp_netman() ->
RunningApps = application:which_applications(),
lists:keymember(grisp_netman, 1, RunningApps).

reboot() ->
case application:get_env(grisp_connect, reboot_cb) of
undefined ->
init:stop();
{ok, undefined} ->
init:stop();
{ok, {Module, Function}}
when is_atom(Module), is_atom(Function) ->
Module:Function();
{ok, Value} ->
error({invalid_env, reboot_cb, Value})
end.

check_inet_ipv4() ->
case get_ip_of_valid_interfaces() of
{ok, {IP1, _, _, _} = IP} when IP1 =/= 127 -> {ok, IP};
Expand Down
Loading