diff --git a/apps/efka/src/docker/efka_docker_container.erl b/apps/efka/src/docker/efka_docker_container.erl index 10acd62..2cd8225 100644 --- a/apps/efka/src/docker/efka_docker_container.erl +++ b/apps/efka/src/docker/efka_docker_container.erl @@ -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]),