Skip to content

Commit

Permalink
stop ecto repo only if its running
Browse files Browse the repository at this point in the history
  • Loading branch information
jarlah committed Nov 20, 2023
1 parent 30f7259 commit 918242b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/ecto.ex
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,17 @@ defmodule Testcontainers.Ecto do
case Testcontainers.start_container(config) do
{:ok, container} ->
System.at_exit(fn _ ->
repo.stop()
if Kernel.function_exported?(repo, :stop, 0) and Process.whereis(repo) != nil do
try do
repo.stop()
catch
_ ->
Logger.log(
"Failed to stop repo #{inspect(repo)} manually. This is just a warning."
)
end
end

Testcontainers.stop_container(container.container_id)
end)

Expand Down

0 comments on commit 918242b

Please sign in to comment.