【发布时间】:2015-09-27 23:56:02
【问题描述】:
我第一次致力于实施主管,但我遇到了无法从文档中弄清楚的问题。具体来说,当我尝试使用SlowRamp.flood 启动我的进程时,我得到{:error, {:invalid_child_spec, []}}。
这是一个非常简单的应用程序,是使用 mix new slow_ramp --sup 制作的。
./lib/slow_ramp.ex中的主文件是:
defmodule SlowRamp do
use Application
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
worker(SlowRamp.Flood, [])
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: SlowRamp.Supervisor]
Supervisor.start_link(children, opts)
end
def flood do
Supervisor.start_child(SlowRamp.Supervisor, [])
end
end
我的子函数/文件位于./lib/SlowRamp/flood.ex 中,如下所示:
defmodule SlowRamp.Flood do
def start_link do
Task.start_link(fn -> start end)
end
defp start do
receive do
{:start, host, caller} ->
send caller, System.cmd("cmd", ["opt"])
end
end
end
任何帮助将不胜感激。谢谢!
【问题讨论】:
标签: elixir erlang-otp