fix sup
This commit is contained in:
parent
4b72498d3a
commit
231ddbad22
@ -14,7 +14,7 @@
|
||||
-behaviour(gen_server).
|
||||
|
||||
%% API
|
||||
-export([start_link/1]).
|
||||
-export([start_link/0]).
|
||||
|
||||
%% gen_server callbacks
|
||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
|
||||
@ -39,10 +39,10 @@
|
||||
%%%===================================================================
|
||||
|
||||
%% @doc Spawns the server and registers the local name (unique)
|
||||
-spec(start_link(Props :: list()) ->
|
||||
-spec(start_link() ->
|
||||
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
|
||||
start_link(Props) when is_list(Props) ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [Props], []).
|
||||
start_link() ->
|
||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_server callbacks
|
||||
@ -53,9 +53,10 @@ start_link(Props) when is_list(Props) ->
|
||||
-spec(init(Args :: term()) ->
|
||||
{ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
|
||||
{stop, Reason :: term()} | ignore).
|
||||
init([Props]) ->
|
||||
init([]) ->
|
||||
erlang:process_flag(trap_exit, true),
|
||||
|
||||
{ok, Props} = application:get_env(iot, zhongdian),
|
||||
%% 创建转发器, 避免阻塞当前进程的创建,因此采用了延时初始化的机制
|
||||
erlang:start_timer(0, self(), create_consumer),
|
||||
%% 启动日志记录器
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
-behaviour(gen_statem).
|
||||
|
||||
%% API
|
||||
-export([start_link/1]).
|
||||
-export([start_link/0]).
|
||||
-export([get_pid/0, forward/3, get_stat/0]).
|
||||
|
||||
%% gen_statem callbacks
|
||||
@ -57,8 +57,8 @@ get_stat() ->
|
||||
%% @doc Creates a gen_statem process which calls Module:init/1 to
|
||||
%% initialize. To ensure a synchronized start-up procedure, this
|
||||
%% function does not return until Module:init/1 has returned.
|
||||
start_link(Opts) when is_list(Opts) ->
|
||||
gen_statem:start_link({local, ?MODULE}, ?MODULE, [Opts], []).
|
||||
start_link() ->
|
||||
gen_statem:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_statem callbacks
|
||||
@ -68,7 +68,9 @@ start_link(Opts) when is_list(Opts) ->
|
||||
%% @doc Whenever a gen_statem is started using gen_statem:start/[3,4] or
|
||||
%% gen_statem:start_link/[3,4], this function is called by the new
|
||||
%% process to initialize.
|
||||
init([Opts]) ->
|
||||
init([]) ->
|
||||
{ok, Opts} = application:get_env(iot, jinzhi),
|
||||
|
||||
PoolSize = proplists:get_value(pool_size, Opts),
|
||||
PriFile = proplists:get_value(pri_key, Opts),
|
||||
Url = proplists:get_value(url, Opts),
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
-behaviour(gen_statem).
|
||||
|
||||
%% API
|
||||
-export([start_link/1]).
|
||||
-export([start_link/0]).
|
||||
-export([get_pid/0, forward/3, get_stat/0]).
|
||||
|
||||
%% gen_statem callbacks
|
||||
@ -57,8 +57,8 @@ get_stat() ->
|
||||
%% @doc Creates a gen_statem process which calls Module:init/1 to
|
||||
%% initialize. To ensure a synchronized start-up procedure, this
|
||||
%% function does not return until Module:init/1 has returned.
|
||||
start_link(Opts) when is_list(Opts) ->
|
||||
gen_statem:start_link({local, ?MODULE}, ?MODULE, [Opts], []).
|
||||
start_link() ->
|
||||
gen_statem:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||
|
||||
%%%===================================================================
|
||||
%%% gen_statem callbacks
|
||||
@ -68,7 +68,9 @@ start_link(Opts) when is_list(Opts) ->
|
||||
%% @doc Whenever a gen_statem is started using gen_statem:start/[3,4] or
|
||||
%% gen_statem:start_link/[3,4], this function is called by the new
|
||||
%% process to initialize.
|
||||
init([Opts]) ->
|
||||
init([]) ->
|
||||
{ok, Opts} = application:get_env(iot, zhongdian),
|
||||
|
||||
erlang:process_flag(trap_exit, true),
|
||||
%% 创建转发器, 避免阻塞当前进程的创建,因此采用了延时初始化的机制
|
||||
erlang:start_timer(0, self(), create_postman),
|
||||
|
||||
@ -26,9 +26,6 @@ start_link() ->
|
||||
%% type => worker(), % optional
|
||||
%% modules => modules()} % optional
|
||||
init([]) ->
|
||||
{ok, MqttOpts} = application:get_env(iot, zhongdian),
|
||||
{ok, JinZhiOpts} = application:get_env(iot, jinzhi),
|
||||
|
||||
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
|
||||
Specs = [
|
||||
#{
|
||||
@ -60,7 +57,7 @@ init([]) ->
|
||||
|
||||
#{
|
||||
id => 'iot_zd_endpoint',
|
||||
start => {'iot_zd_endpoint', start_link, [MqttOpts]},
|
||||
start => {'iot_zd_endpoint', start_link, []},
|
||||
restart => permanent,
|
||||
shutdown => 2000,
|
||||
type => worker,
|
||||
@ -69,7 +66,7 @@ init([]) ->
|
||||
|
||||
#{
|
||||
id => 'iot_jinzhi_endpoint',
|
||||
start => {'iot_jinzhi_endpoint', start_link, [JinZhiOpts]},
|
||||
start => {'iot_jinzhi_endpoint', start_link, []},
|
||||
restart => permanent,
|
||||
shutdown => 2000,
|
||||
type => worker,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user