From be390d42acdb1100b5a5e38d78d61ef452e76e37 Mon Sep 17 00:00:00 2001 From: Feng Date: Thu, 17 Dec 2015 14:12:45 +0800 Subject: [PATCH] stop --- src/emqttd_stats.erl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/emqttd_stats.erl b/src/emqttd_stats.erl index 7135a2315..97d9b8027 100644 --- a/src/emqttd_stats.erl +++ b/src/emqttd_stats.erl @@ -31,7 +31,7 @@ -define(SERVER, ?MODULE). --export([start_link/0]). +-export([start_link/0, stop/0]). %% statistics API. -export([statsfun/1, statsfun/2, @@ -88,6 +88,9 @@ start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). +stop() -> + gen_server:call(?SERVER, stop). + %%------------------------------------------------------------------------------ %% @doc Generate stats fun %% @end @@ -149,6 +152,9 @@ init([]) -> % Tick to publish stats {ok, #state{tick_tref = emqttd_broker:start_tick(tick)}, hibernate}. +handle_call(stop, _From, State) -> + {stop, normal, ok, State}; + handle_call(_Request, _From, State) -> {reply, error, State}.