commit
4c8b18389f
|
@ -141,7 +141,7 @@
|
||||||
%% PubSub
|
%% PubSub
|
||||||
{pubsub, [
|
{pubsub, [
|
||||||
%% default should be scheduler numbers
|
%% default should be scheduler numbers
|
||||||
%% {pool_size, 4}
|
%% {pool_size, 8}
|
||||||
]},
|
]},
|
||||||
%% Bridge
|
%% Bridge
|
||||||
{bridge, [
|
{bridge, [
|
||||||
|
|
|
@ -24,6 +24,5 @@
|
||||||
{runner_base_dir, "${RUNNER_SCRIPT_DIR%/*}"}.
|
{runner_base_dir, "${RUNNER_SCRIPT_DIR%/*}"}.
|
||||||
{runner_etc_dir, "$RUNNER_BASE_DIR/etc"}.
|
{runner_etc_dir, "$RUNNER_BASE_DIR/etc"}.
|
||||||
{runner_log_dir, "$RUNNER_BASE_DIR/log"}.
|
{runner_log_dir, "$RUNNER_BASE_DIR/log"}.
|
||||||
{pipe_dir, "/tmp/$RUNNER_BASE_DIR/"}.
|
{pipe_dir, "/tmp/$RUNNER_SCRIPT/"}.
|
||||||
{runner_user, ""}.
|
{runner_user, ""}.
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ init([]) ->
|
||||||
Name = {emqttd_pubsub, I},
|
Name = {emqttd_pubsub, I},
|
||||||
gproc_pool:add_worker(pubsub, Name, I),
|
gproc_pool:add_worker(pubsub, Name, I),
|
||||||
{Name, {emqttd_pubsub, start_link, [I, Opts]},
|
{Name, {emqttd_pubsub, start_link, [I, Opts]},
|
||||||
permanent, 5000, worker, [emqttd_pubsub]}
|
permanent, 10000, worker, [emqttd_pubsub]}
|
||||||
end, lists:seq(1, PoolSize)),
|
end, lists:seq(1, PoolSize)),
|
||||||
{ok, {{one_for_all, 10, 100}, Children}}.
|
{ok, {{one_for_all, 10, 100}, Children}}.
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ resume_session(Session = #mqtt_session{client_id = ClientId,
|
||||||
{badrpc, Reason} ->
|
{badrpc, Reason} ->
|
||||||
lager:critical("Resume session ~s on remote node ~p failed for ~p",
|
lager:critical("Resume session ~s on remote node ~p failed for ~p",
|
||||||
[ClientId, Node, Reason]),
|
[ClientId, Node, Reason]),
|
||||||
{error, list_to_atom("session_" ++ atom_to_list(Reason))}
|
{error, Reason}
|
||||||
end;
|
end;
|
||||||
false ->
|
false ->
|
||||||
lager:critical("Session ~s died for node ~p down!", [ClientId, Node]),
|
lager:critical("Session ~s died for node ~p down!", [ClientId, Node]),
|
||||||
|
|
|
@ -89,9 +89,9 @@ init([]) ->
|
||||||
|
|
||||||
handle_call({start_trace, Who, LogFile}, _From, State = #state{level = Level, trace_map = TraceMap}) ->
|
handle_call({start_trace, Who, LogFile}, _From, State = #state{level = Level, trace_map = TraceMap}) ->
|
||||||
case lager:trace_file(LogFile, [Who], Level, ?TRACE_OPTIONS) of
|
case lager:trace_file(LogFile, [Who], Level, ?TRACE_OPTIONS) of
|
||||||
{ok, exists} ->
|
{ok, exists} ->
|
||||||
{reply, {error, existed}, State};
|
{reply, {error, existed}, State};
|
||||||
{ok, Trace} ->
|
{ok, Trace} ->
|
||||||
{reply, ok, State#state{trace_map = maps:put(Who, {Trace, LogFile}, TraceMap)}};
|
{reply, ok, State#state{trace_map = maps:put(Who, {Trace, LogFile}, TraceMap)}};
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
{reply, {error, Error}, State}
|
{reply, {error, Error}, State}
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
-module(emqttd_vm).
|
-module(emqttd_vm).
|
||||||
|
|
||||||
|
-author('huangdan').
|
||||||
|
|
||||||
-export([schedulers/0]).
|
-export([schedulers/0]).
|
||||||
|
|
||||||
-export([microsecs/0]).
|
-export([microsecs/0]).
|
||||||
|
@ -39,7 +41,7 @@
|
||||||
get_process_info/0,
|
get_process_info/0,
|
||||||
get_process_gc/0,
|
get_process_gc/0,
|
||||||
get_process_group_leader_info/1,
|
get_process_group_leader_info/1,
|
||||||
get_process_limit/0]).
|
get_process_limit/0]).
|
||||||
|
|
||||||
-export([get_ets_list/0,
|
-export([get_ets_list/0,
|
||||||
get_ets_info/0,
|
get_ets_info/0,
|
||||||
|
@ -59,8 +61,7 @@
|
||||||
sl_alloc,
|
sl_alloc,
|
||||||
ll_alloc,
|
ll_alloc,
|
||||||
fix_alloc,
|
fix_alloc,
|
||||||
std_alloc
|
std_alloc]).
|
||||||
]).
|
|
||||||
|
|
||||||
-define(PROCESS_LIST, [initial_call,
|
-define(PROCESS_LIST, [initial_call,
|
||||||
reductions,
|
reductions,
|
||||||
|
@ -139,8 +140,7 @@
|
||||||
trace_control_word,
|
trace_control_word,
|
||||||
update_cpu_info,
|
update_cpu_info,
|
||||||
version,
|
version,
|
||||||
wordsize
|
wordsize]).
|
||||||
]).
|
|
||||||
|
|
||||||
-define(SOCKET_OPTS, [active,
|
-define(SOCKET_OPTS, [active,
|
||||||
broadcast,
|
broadcast,
|
||||||
|
@ -175,8 +175,8 @@ microsecs() ->
|
||||||
(Mega * 1000000 + Sec) * 1000000 + Micro.
|
(Mega * 1000000 + Sec) * 1000000 + Micro.
|
||||||
|
|
||||||
loads() ->
|
loads() ->
|
||||||
[{load1, ftos(cpu_sup:avg1()/256)},
|
[{load1, ftos(cpu_sup:avg1()/256)},
|
||||||
{load5, ftos(cpu_sup:avg5()/256)},
|
{load5, ftos(cpu_sup:avg5()/256)},
|
||||||
{load15, ftos(cpu_sup:avg15()/256)}].
|
{load15, ftos(cpu_sup:avg15()/256)}].
|
||||||
|
|
||||||
get_system_info() ->
|
get_system_info() ->
|
||||||
|
@ -306,24 +306,20 @@ get_process_list()->
|
||||||
[get_process_list(Pid) || Pid <- processes()].
|
[get_process_list(Pid) || Pid <- processes()].
|
||||||
|
|
||||||
get_process_list(Pid) when is_pid(Pid) ->
|
get_process_list(Pid) when is_pid(Pid) ->
|
||||||
Info = [process_info(Pid, Key) || Key <- ?PROCESS_LIST],
|
[{pid, Pid} | [process_info(Pid, Key) || Key <- ?PROCESS_LIST]].
|
||||||
[{pid, pid_port_fun_to_atom(Pid)}] ++ lists:flatten([convert_pid_info(Item) || Item <- Info]).
|
|
||||||
|
|
||||||
get_process_info() ->
|
get_process_info() ->
|
||||||
[get_process_info(Pid) || Pid <- processes()].
|
[get_process_info(Pid) || Pid <- processes()].
|
||||||
get_process_info(Pid) when is_pid(Pid) ->
|
get_process_info(Pid) when is_pid(Pid) ->
|
||||||
ProcessInfo = [process_info(Pid, Key) || Key <- ?PROCESS_INFO],
|
[process_info(Pid, Key) || Key <- ?PROCESS_INFO].
|
||||||
lists:flatten([convert_pid_info(Item) || Item <- ProcessInfo]).
|
|
||||||
|
|
||||||
get_process_gc() ->
|
get_process_gc() ->
|
||||||
[get_process_gc(Pid) || Pid <- processes()].
|
[get_process_gc(Pid) || Pid <- processes()].
|
||||||
get_process_gc(Pid) when is_pid(Pid) ->
|
get_process_gc(Pid) when is_pid(Pid) ->
|
||||||
GcInfo = [process_info(Pid, Key) || Key <- ?PROCESS_GC],
|
[process_info(Pid, Key) || Key <- ?PROCESS_GC].
|
||||||
lists:flatten([convert_pid_info(E) || E <- GcInfo]).
|
|
||||||
|
|
||||||
get_process_group_leader_info(LeaderPid) when is_pid(LeaderPid) ->
|
get_process_group_leader_info(LeaderPid) when is_pid(LeaderPid) ->
|
||||||
LeaderInfo = [{Key, Value}|| {Key, Value} <- process_info(LeaderPid), lists:member(Key, ?PROCESS_INFO)],
|
[{Key, Value}|| {Key, Value} <- process_info(LeaderPid), lists:member(Key, ?PROCESS_INFO)].
|
||||||
lists:flatten([convert_pid_info(E) || E <- LeaderInfo]).
|
|
||||||
|
|
||||||
get_process_limit() ->
|
get_process_limit() ->
|
||||||
erlang:system_info(process_limit).
|
erlang:system_info(process_limit).
|
||||||
|
@ -453,41 +449,7 @@ mapping([], Acc) ->
|
||||||
mapping([{owner, V}|Entries], Acc) when is_pid(V) ->
|
mapping([{owner, V}|Entries], Acc) when is_pid(V) ->
|
||||||
OwnerInfo = process_info(V),
|
OwnerInfo = process_info(V),
|
||||||
Owner = proplists:get_value(registered_name, OwnerInfo, undefined),
|
Owner = proplists:get_value(registered_name, OwnerInfo, undefined),
|
||||||
mapping(Entries, [{owner, pid_port_fun_to_atom(Owner)}|Acc]);
|
mapping(Entries, [{owner, Owner}|Acc]);
|
||||||
mapping([{Key, Value}|Entries], Acc) ->
|
mapping([{Key, Value}|Entries], Acc) ->
|
||||||
mapping(Entries, [{Key, pid_port_fun_to_atom(Value)}|Acc]).
|
mapping(Entries, [{Key, Value}|Acc]).
|
||||||
|
|
||||||
%ip_to_binary(Tuple) ->
|
|
||||||
% iolist_to_binary(string:join(lists:map(fun integer_to_list/1, tuple_to_list(Tuple)), ".")).
|
|
||||||
|
|
||||||
convert_pid_info({initial_call,{_M, F, _A}}) ->
|
|
||||||
{initial_call, F};
|
|
||||||
convert_pid_info({current_function, {M, F, A}}) ->
|
|
||||||
{current_function, list_to_atom(lists:concat([atom_to_list(M),":",atom_to_list(F),"/",integer_to_list(A)]))};
|
|
||||||
convert_pid_info({suspending, List}) ->
|
|
||||||
{suspending, [pid_port_fun_to_atom(E) || E <- List]};
|
|
||||||
convert_pid_info({binary, List}) ->
|
|
||||||
{binary,[tuple_to_list(E) || E <- List]};
|
|
||||||
convert_pid_info({Key, Term}) when is_pid(Term) or is_port(Term) or is_function(Term) ->
|
|
||||||
{Key, pid_port_fun_to_atom(Term)};
|
|
||||||
convert_pid_info(Item) ->
|
|
||||||
Item.
|
|
||||||
|
|
||||||
%convert_port_info({name, Name}) ->
|
|
||||||
% {name, list_to_binary(Name)};
|
|
||||||
%convert_port_info({links, List}) ->
|
|
||||||
% {links, [pid_port_fun_to_atom(Item) || Item <- List]};
|
|
||||||
%convert_port_info({connected, Pid}) ->
|
|
||||||
% erlang:process_info(Pid, registered_name);
|
|
||||||
%convert_port_info(Item) ->
|
|
||||||
% Item.
|
|
||||||
|
|
||||||
|
|
||||||
pid_port_fun_to_atom(Term) when is_pid(Term) ->
|
|
||||||
erlang:list_to_atom(pid_to_list(Term));
|
|
||||||
pid_port_fun_to_atom(Term) when is_port(Term) ->
|
|
||||||
erlang:list_to_atom(erlang:port_to_list(Term));
|
|
||||||
pid_port_fun_to_atom(Term) when is_function(Term) ->
|
|
||||||
erlang:list_to_atom(erlang:fun_to_list(Term));
|
|
||||||
pid_port_fun_to_atom(Term) ->
|
|
||||||
Term.
|
|
||||||
|
|
Loading…
Reference in New Issue