Skip to content

Instantly share code, notes, and snippets.

@kenpratt
Created January 19, 2010 02:59
Show Gist options
  • Save kenpratt/280618 to your computer and use it in GitHub Desktop.
Save kenpratt/280618 to your computer and use it in GitHub Desktop.
-module(echo_supervisor).
-behaviour(supervisor).
%% API
-export([start_link/0]).
%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
%%====================================================================
%% API
%%====================================================================
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
%%====================================================================
%% Supervisor callbacks
%%====================================================================
init([]) ->
Dog =
{dog,
{echo_server, start_link, [dog, "Woof!", 3000]},
permanent, 2000, worker, dynamic},
HungryCat =
{hungry_cat,
{echo_server, start_link, [hungry_cat, "*meow*", 4000]},
permanent, 2000, worker, dynamic},
HappyCat =
{happy_cat,
{echo_server, start_link, [happy_cat, "*purrrrrr*", 1500]},
permanent, 2000, worker, dynamic},
Children = [Dog, HungryCat, HappyCat],
{ok, {{one_for_one, 3, 10}, Children}}.
%%====================================================================
%% Internal functions
%%====================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment