otp - Elixir :invalid_child_spec for supervised process. Can't figure out why -


i'm working on implementing supervisor first time , i'm running issues can't figure out documentation. specifically, when try start process using slowramp.flood {:error, {:invalid_child_spec, []}}.

this simple application , made using mix new slow_ramp --sup.

the main file in ./lib/slow_ramp.ex is:

defmodule slowramp   use application    # see http://elixir-lang.org/docs/stable/elixir/application.html   # more information on otp applications   def start(_type, _args)     import supervisor.spec, warn: false      children = [       worker(slowramp.flood, [])     ]      # see http://elixir-lang.org/docs/stable/elixir/supervisor.html     # other strategies , supported options     opts = [strategy: :one_for_one, name: slowramp.supervisor]     supervisor.start_link(children, opts)   end    def flood     supervisor.start_child(slowramp.supervisor, [])   end end 

my child function / file in ./lib/slowramp/flood.ex , looks this:

defmodule slowramp.flood   def start_link     task.start_link(fn -> start end)   end    defp start     receive       {:start, host, caller} ->         send caller, system.cmd("cmd", ["opt"])     end   end end 

any appreciated. thanks!

the problem on

supervisor.start_child(slowramp.supervisor, []) 

you need valid child specification, like:

def flood   import supervisor.spec   supervisor.start_child(slowramp.supervisor, worker(slowramp.flood, [], [id: :foo])) end 

thats reason telling child spec invalid


Comments