Created
March 22, 2016 12:47
-
-
Save bcardarella/d0ba31dc5d1fb3a017b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MySupervisor do | |
def start | |
import Supervisor.Spec | |
children = [ | |
worker(FooBar, []) | |
] | |
opts = [strategy: :one_for_one, name: MySupervisor] | |
Supervisor.start_link(children, opts) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule FooBar do | |
require Logger | |
def start_link do | |
{:ok, spawn(__MODULE__, :foo, [0])} | |
end | |
def foo(count) do | |
Logger.info(count) | |
if count > 5 do | |
raise "Ruh roh!" | |
end | |
:timer.sleep 2000 | |
foo(count + 1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment