配置多个回购,我尝试使用Ecto配置在我的药剂应用的两个回购。
我需要帮助配置它们,所以它们都与一个one_for_one战略独立监督;我认为这是正确的,并使用它们将重新启动在药剂应用
回购-A和回购-B将意味着过程
mix.exs设置:
def application do
[applications: [:logger, :tds, :tds_ecto, :ecto, :httpoison, :csvlixir],
mod: {MyApp, []}]
end
MyApp_app.ex
下面段:
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
supervisor(MyApp.Repo-A, []),
worker(Task, [MyAppModule, :work, []], restart: :temporary),
supervisor(MyApp.Repo-B, []),
worker(Task, [MyAppModule, :work, []], restart: :temporary)
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
defmodule Repo-A do
use Ecto.Repo, otp_app: :myapp
end
defmodule Repo-B do
use Ecto.Repo, otp_app: :myapp
end
当我我mix run
得到如下 - 我不知道如何正确界定ID。
** (Mix) Could not start application myapp: exited in: MyApp.start(:normal, [])
** (EXIT) an exception was raised:
** (ArgumentError) duplicated id Task found in the supervisor specification, please explicitly pass the :id option when defining this worker/supervisor
我不认为这个问题是关系到外生的,是不是叫'工人的结果(任务,[MyAppModule,:work,[]],重启:: temporary),两次? – Gazler
@Gazler - 是的,同意不与外生的问题 - 它只是我的小白使用:)我不知道如何配置主管和工人两个回购协议 - 我敢肯定,我贴的代码是错误的... –