Skip to content

Instantly share code, notes, and snippets.

@greggy
Created December 7, 2011 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greggy/1442274 to your computer and use it in GitHub Desktop.
Save greggy/1442274 to your computer and use it in GitHub Desktop.
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
start_proxy(SessionPid, ChannelID) ->
Name = list_to_atom(ChannelID),
supervisor:terminate_child(proxy_sup, Name),
supervisor:delete_child(proxy_sup, Name),
SpecProxy = {Name, {proxy, start_link, [SessionPid, ChannelID, Name]},
transient, 2000, worker, [Name]},
case supervisor:start_child(?SERVER, SpecProxy) of
{ok, Pid} -> {ok, Pid};
{error, {already_started, Pid}} -> {ok, Pid};
{error, Error} -> {error, Error}
end.
init([]) ->
{ok, {{one_for_one, 3, 1}, []}}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment