Skip to content

Commit

Permalink
Merge pull request #9 from SmartColumbusOS/auto_start
Browse files Browse the repository at this point in the history
Changed to auto start and stop app, can be turned off
  • Loading branch information
jeffgrunewald authored Mar 11, 2019
2 parents f210eed + 6381d63 commit de8a4d2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/divo/integration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit de8a4d2

Please sign in to comment.