don't restart postgrex
This commit is contained in:
parent
09bd1d12c1
commit
6cda360fea
5 changed files with 25 additions and 11 deletions
|
@ -47,7 +47,7 @@ defmodule Pleroma.Config.Loader do
|
|||
@spec filter_group(atom(), keyword()) :: keyword()
|
||||
def filter_group(group, configs) do
|
||||
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
|
||||
|
|
|
@ -46,14 +46,6 @@ defmodule Pleroma.Config.TransferTask do
|
|||
with {_, true} <- {:configurable, Config.get(:configurable_from_database)} do
|
||||
# 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} =
|
||||
(Repo.all(ConfigDB) ++ deleted_settings)
|
||||
|> Enum.map(&transform_and_merge/1)
|
||||
|
@ -65,10 +57,20 @@ defmodule Pleroma.Config.TransferTask do
|
|||
|
||||
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
|
||||
|> Enum.map(&update/1)
|
||||
|> Enum.uniq()
|
||||
|> Enum.reject(&(&1 in reject_restart))
|
||||
|> Enum.reject(&(&1 in reject))
|
||||
|> maybe_set_pleroma_last()
|
||||
|> Enum.each(&restart(started_applications, &1, Config.get(:env)))
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
refute Application.get_env(:pleroma, :test_key)
|
||||
refute Application.get_env(:idna, :test_key)
|
||||
refute Application.get_env(:quack, :test_key)
|
||||
refute Application.get_env(:postgrex, :test_key)
|
||||
initial = Application.get_env(:logger, :level)
|
||||
|
||||
ConfigDB.create(%{
|
||||
|
@ -36,6 +37,12 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
value: [:test_value1, :test_value2]
|
||||
})
|
||||
|
||||
ConfigDB.create(%{
|
||||
group: ":postgrex",
|
||||
key: ":test_key",
|
||||
value: :value
|
||||
})
|
||||
|
||||
ConfigDB.create(%{group: ":logger", key: ":level", value: :debug})
|
||||
|
||||
TransferTask.start_link([])
|
||||
|
@ -44,11 +51,13 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
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(:logger, :level) == :debug
|
||||
assert Application.get_env(:postgrex, :test_key) == :value
|
||||
|
||||
on_exit(fn ->
|
||||
Application.delete_env(:pleroma, :test_key)
|
||||
Application.delete_env(:idna, :test_key)
|
||||
Application.delete_env(:quack, :test_key)
|
||||
Application.delete_env(:postgrex, :test_key)
|
||||
Application.put_env(:logger, :level, initial)
|
||||
end)
|
||||
end
|
||||
|
|
2
test/fixtures/config/temp.secret.exs
vendored
2
test/fixtures/config/temp.secret.exs
vendored
|
@ -7,3 +7,5 @@ config :pleroma, :second_setting, key: "value2", key2: ["Activity"]
|
|||
config :quack, level: :info
|
||||
|
||||
config :pleroma, Pleroma.Repo, pool: Ecto.Adapters.SQL.Sandbox
|
||||
|
||||
config :postgrex, :json_library, Poison
|
||||
|
|
|
@ -38,7 +38,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
on_exit(fn -> Application.put_env(:quack, :level, initial) end)
|
||||
end
|
||||
|
||||
test "settings are migrated to db" do
|
||||
test "filtered settings are migrated to db" do
|
||||
assert Repo.all(ConfigDB) == []
|
||||
|
||||
Mix.Tasks.Pleroma.Config.migrate_to_db("test/fixtures/config/temp.secret.exs")
|
||||
|
@ -47,6 +47,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
config2 = ConfigDB.get_by_params(%{group: ":pleroma", key: ":second_setting"})
|
||||
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: ":postgrex", key: ":json_library"})
|
||||
|
||||
assert ConfigDB.from_binary(config1.value) == [key: "value", key2: [Repo]]
|
||||
assert ConfigDB.from_binary(config2.value) == [key: "value2", key2: ["Activity"]]
|
||||
|
|
Loading…
Reference in a new issue