-module(template).
-record(stat, {}).
-export([start/1, stop/0, reload/0, init/1, loop/1]).
start(Opts) ->
Stat = parse_opts(Opts),
Pid = erlang:spawn(fun() -> init(Stat) end),
register(?MODULE, Pid),
{ok, Pid}.
stop() ->
case whereis(?MODULE) of
undefined ->
ok;
Pid ->
erlang:exit(Pid, kill)
end.
reload() ->
code:purge(?MODULE),
code:delete(?MODULE).
init(Stat) ->
%% Do Something
loop(Stat).
loop(Stat) ->
receive
Any ->
%% Process Received Message
?MODULE:loop(Stat)
after
1000 ->
?MODULE:loop(Stat)
end.
parse_opts(Opts) ->
#stat{}.