This commit is contained in:
anlicheng 2025-04-30 14:09:12 +08:00
parent 86b44a84eb
commit 3c0e7d6510

View File

@ -166,17 +166,17 @@ handle_info({Port, {exit_status, Code}}, State = #state{port = Port, service = S
%% with Reason. The return value is ignored.
-spec(terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()),
State :: #state{}) -> term()).
terminate(Reason, _State = #state{port = Port}) ->
terminate(Reason, _State = #state{port = Port}) when is_port(Port) ->
lager:debug("[efka_micro_service] terminate with reason: ~p", [Reason]),
case is_port(Port) of
true ->
case erlang:port_info(Port, os_pid) of
undefined ->
ok;
{os_pid, OsPid} ->
os:cmd(io_lib:format("kill -9 ~p", [OsPid]))
end
case erlang:port_info(Port, os_pid) of
undefined ->
ok;
{os_pid, OsPid} ->
os:cmd(io_lib:format("kill -9 ~p", [OsPid]))
end,
ok;
terminate(Reason, _State = #state{}) ->
lager:debug("[efka_micro_service] terminate with reason: ~p", [Reason]),
ok.
%% @private