Skip to content

Instantly share code, notes, and snippets.

@yongboy
Created October 24, 2012 09:41
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 yongboy/3945155 to your computer and use it in GitHub Desktop.
Save yongboy/3945155 to your computer and use it in GitHub Desktop.
tcp_server_sup
-module(tcp_server_sup).
-author('yongboy@gmail.com').
-behaviour(supervisor).
-export([start_link/1, start_child/0]).
-export([init/1]).
-define(SERVER, ?MODULE).
start_link(LSock) ->
supervisor:start_link({local, ?SERVER}, ?MODULE, [LSock]).
start_child() ->
supervisor:start_child(?SERVER, []).
init([LSock]) ->
Server = {tcp_server_handler, {tcp_server_handler, start_link, [LSock]},
temporary, brutal_kill, worker, [tcp_server_handler]},
Children = [Server],
RestartStrategy = {simple_one_for_one, 0, 1},
{ok, {RestartStrategy, Children}}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment