Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (23 sloc) 607 Bytes
-module (server_util).
-compile(export_all).
start (ServerName, {Module, Function, Args}) ->
global:trans({ServerName, ServerName}, fun
() ->
case global:whereis_name(ServerName) of
undefined ->
Pid = spawn(Module, Function, Args),
global:register_name(ServerName, Pid);
_ ->
ok
end
end).
stop (ServerName) ->
global:trans({ServerName, ServerName}, fun
() ->
case global:whereis_name(ServerName) of
undefined ->
ok;
_ ->
global:send(ServerName, shutdown)
end
end).