From 6381d63f90c8e2319993f0d80236d6affd7787c5 Mon Sep 17 00:00:00 2001 From: Brian Balser Date: Mon, 11 Mar 2019 14:45:26 -0400 Subject: [PATCH] Changed to auto start and stop app, can be turned off --- lib/divo/integration.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/divo/integration.ex b/lib/divo/integration.ex index a1fef4c..3514e8a 100644 --- a/lib/divo/integration.ex +++ b/lib/divo/integration.ex @@ -7,17 +7,19 @@ defmodule Divo.Integration do """ defmacro __using__(opts \\ []) do + auto_start = Keyword.get(opts, :auto_start, true) + quote do import Mix.Tasks.Docker.{Start, Kill} setup_all do Mix.Tasks.Docker.Start.run(unquote(opts)) - Mix.Project.config() - |> Keyword.get(:app) - |> Application.ensure_all_started() + app = Mix.Project.config() |> Keyword.get(:app) + if unquote(auto_start), do: Application.ensure_all_started(app) on_exit(fn -> + if unquote(auto_start), do: Application.stop(app) Mix.Tasks.Docker.Kill.run(unquote(opts)) end)