Skip to content

Instantly share code, notes, and snippets.

@killme2008
Created October 23, 2015 03:46
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 killme2008/a1ddf2b0fee80f6e137b to your computer and use it in GitHub Desktop.
Save killme2008/a1ddf2b0fee80f6e137b to your computer and use it in GitHub Desktop.
Elixir supervisor example
defmodule CounterSupervisor do
use Supervisor
def start_link(v \\ 0) do
Supervisor.start_link(__MODULE__, v)
end
@counter_name Counter
#supervisor callback
def init(v) do
children = [
worker(Counter, [v, [name: @counter_name]])
]
supervise(children, strategy: :one_for_one)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment