Last active
May 24, 2016 21:15
-
-
Save barsukov/e6ef2722b69ed488880564c329b61805 to your computer and use it in GitHub Desktop.
not working superviser
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 Lucas do | |
use Application | |
# Import helpers for defining supervisors | |
import Supervisor.Spec | |
def start(_type, _args) do | |
IO.puts "starting" | |
# This time, we don't pass any argument because | |
# the argument will be given when we start the child | |
children = [ | |
worker(Poller, [%{timeout: 1, update_id: 0}], restart: :transient) | |
] | |
# Start the supervisor with our one child | |
{:ok, sup_pid} = Supervisor.start_link(children, strategy: :simple_one_for_one) | |
{:ok, pid} = Supervisor.start_child(sup_pid, []) | |
end | |
end | |
defmodule Poller do | |
use GenServer | |
require Logger | |
def start_link(state) do | |
GenServer.start_link(__MODULE__, state) | |
end | |
def init(state) do | |
IO.puts "Pooling server started" | |
spawn fn -> | |
handle_cast(:start_pool, state) | |
end | |
{:ok, state} | |
end | |
def handle_cast(:start_pool, state) do | |
lol | |
{:noreply, state} | |
end | |
def lol do | |
throw("x") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment