Skip to content

Instantly share code, notes, and snippets.

@barsukov
Last active May 24, 2016 21:15
Show Gist options
  • Save barsukov/e6ef2722b69ed488880564c329b61805 to your computer and use it in GitHub Desktop.
Save barsukov/e6ef2722b69ed488880564c329b61805 to your computer and use it in GitHub Desktop.
not working superviser
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