fix
This commit is contained in:
parent
333d51613e
commit
8d869f5bc0
@ -94,6 +94,7 @@ init([Service = #micro_service{service_id = ServiceId, work_dir = WorkDir0, stat
|
||||
case file:read_file(WorkDir ++ "manifest.json") of
|
||||
{ok, ManifestInfo} ->
|
||||
Manifest = jiffy:decode(ManifestInfo, [return_maps]),
|
||||
lager:debug("main: ~p", [Manifest]),
|
||||
case check_manifest(Manifest) of
|
||||
ok ->
|
||||
%% 数据的状态和运行状态是2回事
|
||||
@ -241,9 +242,9 @@ handle_info({'DOWN', _Ref, process, ChannelPid, Reason}, State = #state{channel_
|
||||
%% 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{os_pid = OSPid}) ->
|
||||
lager:debug("[efka_micro_service] terminate with reason: ~p", [Reason]),
|
||||
kill_os_pid(Port),
|
||||
kill_os_pid(OSPid),
|
||||
ok.
|
||||
|
||||
%% @private
|
||||
@ -265,7 +266,7 @@ check_manifest(Manifest) when is_map(Manifest) ->
|
||||
check_manifest0(RequiredKeys, Manifest).
|
||||
|
||||
check_manifest0([], _Manifest) ->
|
||||
true;
|
||||
ok;
|
||||
check_manifest0([<<"serivce_id">>|T], Manifest) ->
|
||||
case maps:find(<<"serivce_id">>, Manifest) of
|
||||
error ->
|
||||
@ -363,7 +364,7 @@ kill_service(WorkDir0, ExecCmd0, OSPid) when is_binary(WorkDir0) ->
|
||||
|
||||
%% 启动微服务
|
||||
-spec boot_service(WorkDir :: binary(), ExecCmd :: binary() | [binary()]) -> {ok, Port :: port()} | {error, Reason :: binary()}.
|
||||
boot_service(WorkDir0, ExecCmd0) when is_binary(WorkDir0), is_binary(ExecCmd0) ->
|
||||
boot_service(WorkDir0, ExecCmd0) when is_binary(WorkDir0), is_binary(ExecCmd0); is_list(ExecCmd0) ->
|
||||
{RealExecCmd, PortSettings} = make_cmd(WorkDir0, ExecCmd0),
|
||||
Port = erlang:open_port({spawn_executable, RealExecCmd}, PortSettings),
|
||||
{ok, Port}.
|
||||
|
||||
@ -55,7 +55,7 @@ init([]) ->
|
||||
service_name = <<"测试服务">>,
|
||||
from = <<"master">>,
|
||||
%% 工作目录
|
||||
work_dir = <<"/tmp/test/">>,
|
||||
work_dir = <<"/usr/local/code/tmp/test/">>,
|
||||
params = <<"">>,
|
||||
metrics = <<"">>,
|
||||
%% 状态: 0: 停止, 1: 运行中
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user