From 880f363792eb76c3ccc2560dcf56cb40500e37a5 Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Fri, 17 Jul 2020 17:37:55 -0700 Subject: [PATCH] Remove (supervisor) opts from Omnibot.Plugin opts, update Plugin.Supervisor to use :one_for_all strategy by default Plugin opts no longer contains options for the supervisors that watch plugins, and said supervisors now adopt the one_for_all strategy. This is because these servers *generally* need one another to stay alive. Signed-off-by: Alek Ratzloff --- lib/plugin/plugin.ex | 3 +-- lib/plugin/supervisor.ex | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/plugin/plugin.ex b/lib/plugin/plugin.ex index 11492d6..d56e33f 100644 --- a/lib/plugin/plugin.ex +++ b/lib/plugin/plugin.ex @@ -1,5 +1,5 @@ defmodule Omnibot.Plugin do - @default_opts [include_base: true, opts: [strategy: :one_for_one]] + @default_opts [include_base: true] # strategy: one_for_all defmodule CfgState do use Agent @@ -16,7 +16,6 @@ defmodule Omnibot.Plugin do def update_state(pid, fun, timeout \\ 5000) do Agent.update(pid, fn {cfg, state} -> {cfg, apply(fun, [state])} end, timeout) - #Agent.update(pid, &{&1, apply(fun, [&1])}, timeout) end end diff --git a/lib/plugin/supervisor.ex b/lib/plugin/supervisor.ex index bc4c954..e563cbf 100644 --- a/lib/plugin/supervisor.ex +++ b/lib/plugin/supervisor.ex @@ -22,6 +22,6 @@ defmodule Omnibot.Plugin.Supervisor do @impl true def init({plugin, cfg}) when is_atom(plugin) do children = plugin.plugin_children(cfg) - Supervisor.init(children, strategy: :one_for_one) + Supervisor.init(children, strategy: :one_for_all) end end