This commit is contained in:
anlicheng 2025-05-07 11:19:31 +08:00
parent 05111807ca
commit cec6e42a0d

View File

@ -185,10 +185,9 @@ handle_call(start_service, _From, State = #state{running_status = ?STATUS_STOPPE
%%
case efka_manifest:startup(Manifest) of
{ok, Port} ->
%%
micro_service_model:start_service(ServiceId),
{os_pid, OSPid} = erlang:port_info(Port, os_pid),
lager:debug("start_service port: ~p, os_pid: ~p", [Port, OSPid]),
%%
ok = micro_service_model:change_status(ServiceId, 1),
{reply, ok, State#state{running_status = ?STATUS_RUNNING, port = Port, os_pid = OSPid}};
{error, Reason} ->
@ -205,10 +204,8 @@ handle_call(stop_service, _From, State = #state{running_status = ?STATUS_RUNNING
%% 使stop指令, 使kill指令
kill_os_pid(OSPid),
micro_service_model:stop_service(ServiceId),
erlang:is_port(Port) andalso erlang:port_close(Port),
lager:debug("port: ~p, os_pid: ~p, will closed", [Port, OSPid]),
ok = micro_service_model:change_status(ServiceId, 0),
{reply, ok, State#state{port = undefined, os_pid = undefined, running_status = ?STATUS_STOPPED}};