This commit is contained in:
anlicheng 2025-09-12 17:44:14 +08:00
parent 819ac30a5a
commit ee1c025cd5

View File

@ -95,21 +95,14 @@ init([ContainerId]) ->
%% supervisor进程通过exit(ChildPid, shutdown)terminate函数被调用
erlang:process_flag(trap_exit, true),
ExecCmd0 = <<>>,
Args0 = [],
PortSettings = [
{args, [binary_to_list(A) || A <- Args0]},
exit_status
],
ExecCmd = binary_to_list(ExecCmd0),
case catch erlang:open_port({spawn_executable, ExecCmd}, PortSettings) of
Port when is_port(Port) ->
case startup(<<>>, []) of
{ok, Port} ->
{os_pid, OSPid} = erlang:port_info(Port, os_pid),
lager:debug("[efka_service] service: ~p, port: ~p, boot_service success os_pid: ~p", [ContainerId, Port, OSPid]),
{ok, #state{container_id = ContainerId, port = Port, os_pid = OSPid}};
_Other ->
{error, Reason} ->
lager:debug("[efka_service] service: ~p", [ContainerId]),
{stop, <<"exec command startup failed">>}
{stop, Reason}
end.
%% @private
@ -187,7 +180,7 @@ handle_cast(_Request, State = #state{}) ->
{stop, Reason :: term(), NewState :: #state{}}).
%%
handle_info({timeout, _, reboot_service}, State = #state{service_id = ServiceId, manifest = Manifest}) ->
case efka_manifest:startup(Manifest) of
case startup(Manifest, []) of
{ok, Port} ->
{os_pid, OSPid} = erlang:port_info(Port, os_pid),
lager:debug("[efka_service] service_id: ~p, reboot success, port: ~p, os_pid: ~p", [ServiceId, Port, OSPid]),