don't restart postgrex
This commit is contained in:
parent
09bd1d12c1
commit
6cda360fea
|
@ -47,7 +47,7 @@ defp filter(configs) do
|
||||||
@spec filter_group(atom(), keyword()) :: keyword()
|
@spec filter_group(atom(), keyword()) :: keyword()
|
||||||
def filter_group(group, configs) do
|
def filter_group(group, configs) do
|
||||||
Enum.reject(configs[group], fn {key, _v} ->
|
Enum.reject(configs[group], fn {key, _v} ->
|
||||||
key in @reject_keys or (group == :phoenix and key == :serve_endpoints)
|
key in @reject_keys or (group == :phoenix and key == :serve_endpoints) or group == :postgrex
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,14 +46,6 @@ def load_and_update_env(deleted_settings \\ [], restart_pleroma? \\ true) do
|
||||||
with {_, true} <- {:configurable, Config.get(:configurable_from_database)} do
|
with {_, true} <- {:configurable, Config.get(:configurable_from_database)} do
|
||||||
# We need to restart applications for loaded settings take effect
|
# We need to restart applications for loaded settings take effect
|
||||||
|
|
||||||
# TODO: some problem with prometheus after restart!
|
|
||||||
reject_restart =
|
|
||||||
if restart_pleroma? do
|
|
||||||
[nil, :prometheus]
|
|
||||||
else
|
|
||||||
[:pleroma, nil, :prometheus]
|
|
||||||
end
|
|
||||||
|
|
||||||
{logger, other} =
|
{logger, other} =
|
||||||
(Repo.all(ConfigDB) ++ deleted_settings)
|
(Repo.all(ConfigDB) ++ deleted_settings)
|
||||||
|> Enum.map(&transform_and_merge/1)
|
|> Enum.map(&transform_and_merge/1)
|
||||||
|
@ -65,10 +57,20 @@ def load_and_update_env(deleted_settings \\ [], restart_pleroma? \\ true) do
|
||||||
|
|
||||||
started_applications = Application.started_applications()
|
started_applications = Application.started_applications()
|
||||||
|
|
||||||
|
# TODO: some problem with prometheus after restart!
|
||||||
|
reject = [nil, :prometheus, :postgrex]
|
||||||
|
|
||||||
|
reject =
|
||||||
|
if restart_pleroma? do
|
||||||
|
reject
|
||||||
|
else
|
||||||
|
[:pleroma | reject]
|
||||||
|
end
|
||||||
|
|
||||||
other
|
other
|
||||||
|> Enum.map(&update/1)
|
|> Enum.map(&update/1)
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|> Enum.reject(&(&1 in reject_restart))
|
|> Enum.reject(&(&1 in reject))
|
||||||
|> maybe_set_pleroma_last()
|
|> maybe_set_pleroma_last()
|
||||||
|> Enum.each(&restart(started_applications, &1, Config.get(:env)))
|
|> Enum.each(&restart(started_applications, &1, Config.get(:env)))
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ test "transfer config values from db to env" do
|
||||||
refute Application.get_env(:pleroma, :test_key)
|
refute Application.get_env(:pleroma, :test_key)
|
||||||
refute Application.get_env(:idna, :test_key)
|
refute Application.get_env(:idna, :test_key)
|
||||||
refute Application.get_env(:quack, :test_key)
|
refute Application.get_env(:quack, :test_key)
|
||||||
|
refute Application.get_env(:postgrex, :test_key)
|
||||||
initial = Application.get_env(:logger, :level)
|
initial = Application.get_env(:logger, :level)
|
||||||
|
|
||||||
ConfigDB.create(%{
|
ConfigDB.create(%{
|
||||||
|
@ -36,6 +37,12 @@ test "transfer config values from db to env" do
|
||||||
value: [:test_value1, :test_value2]
|
value: [:test_value1, :test_value2]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ConfigDB.create(%{
|
||||||
|
group: ":postgrex",
|
||||||
|
key: ":test_key",
|
||||||
|
value: :value
|
||||||
|
})
|
||||||
|
|
||||||
ConfigDB.create(%{group: ":logger", key: ":level", value: :debug})
|
ConfigDB.create(%{group: ":logger", key: ":level", value: :debug})
|
||||||
|
|
||||||
TransferTask.start_link([])
|
TransferTask.start_link([])
|
||||||
|
@ -44,11 +51,13 @@ test "transfer config values from db to env" do
|
||||||
assert Application.get_env(:idna, :test_key) == [live: 15, com: 35]
|
assert Application.get_env(:idna, :test_key) == [live: 15, com: 35]
|
||||||
assert Application.get_env(:quack, :test_key) == [:test_value1, :test_value2]
|
assert Application.get_env(:quack, :test_key) == [:test_value1, :test_value2]
|
||||||
assert Application.get_env(:logger, :level) == :debug
|
assert Application.get_env(:logger, :level) == :debug
|
||||||
|
assert Application.get_env(:postgrex, :test_key) == :value
|
||||||
|
|
||||||
on_exit(fn ->
|
on_exit(fn ->
|
||||||
Application.delete_env(:pleroma, :test_key)
|
Application.delete_env(:pleroma, :test_key)
|
||||||
Application.delete_env(:idna, :test_key)
|
Application.delete_env(:idna, :test_key)
|
||||||
Application.delete_env(:quack, :test_key)
|
Application.delete_env(:quack, :test_key)
|
||||||
|
Application.delete_env(:postgrex, :test_key)
|
||||||
Application.put_env(:logger, :level, initial)
|
Application.put_env(:logger, :level, initial)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
2
test/fixtures/config/temp.secret.exs
vendored
2
test/fixtures/config/temp.secret.exs
vendored
|
@ -7,3 +7,5 @@
|
||||||
config :quack, level: :info
|
config :quack, level: :info
|
||||||
|
|
||||||
config :pleroma, Pleroma.Repo, pool: Ecto.Adapters.SQL.Sandbox
|
config :pleroma, Pleroma.Repo, pool: Ecto.Adapters.SQL.Sandbox
|
||||||
|
|
||||||
|
config :postgrex, :json_library, Poison
|
||||||
|
|
|
@ -38,7 +38,7 @@ test "error if file with custom settings doesn't exist" do
|
||||||
on_exit(fn -> Application.put_env(:quack, :level, initial) end)
|
on_exit(fn -> Application.put_env(:quack, :level, initial) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "settings are migrated to db" do
|
test "filtered settings are migrated to db" do
|
||||||
assert Repo.all(ConfigDB) == []
|
assert Repo.all(ConfigDB) == []
|
||||||
|
|
||||||
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
|
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
|
||||||
|
@ -47,6 +47,7 @@ test "settings are migrated to db" do
|
||||||
config2 = ConfigDB.get_by_params(%{group: ":pleroma", key: ":second_setting"})
|
config2 = ConfigDB.get_by_params(%{group: ":pleroma", key: ":second_setting"})
|
||||||
config3 = ConfigDB.get_by_params(%{group: ":quack", key: ":level"})
|
config3 = ConfigDB.get_by_params(%{group: ":quack", key: ":level"})
|
||||||
refute ConfigDB.get_by_params(%{group: ":pleroma", key: "Pleroma.Repo"})
|
refute ConfigDB.get_by_params(%{group: ":pleroma", key: "Pleroma.Repo"})
|
||||||
|
refute ConfigDB.get_by_params(%{group: ":postgrex", key: ":json_library"})
|
||||||
|
|
||||||
assert ConfigDB.from_binary(config1.value) == [key: "value", key2: [Repo]]
|
assert ConfigDB.from_binary(config1.value) == [key: "value", key2: [Repo]]
|
||||||
assert ConfigDB.from_binary(config2.value) == [key: "value2", key2: ["Activity"]]
|
assert ConfigDB.from_binary(config2.value) == [key: "value2", key2: ["Activity"]]
|
||||||
|
|
Loading…
Reference in a new issue