From 830c6fba9b48a5986ee24f515bf153f3718e6e62 Mon Sep 17 00:00:00 2001 From: simonLab Date: Thu, 15 Feb 2018 09:42:04 +0000 Subject: [PATCH] use new Phx 1.3 application file, #168 --- config/dev.exs | 14 +++++------ lib/dwylbot.ex | 49 ++++++++++++++++++-------------------- lib/dwylbot/application.ex | 31 ++++++++++++++++++++++++ lib/dwylbot/repo.ex | 3 --- mix.exs | 2 +- 5 files changed, 62 insertions(+), 37 deletions(-) create mode 100644 lib/dwylbot/application.ex delete mode 100644 lib/dwylbot/repo.ex diff --git a/config/dev.exs b/config/dev.exs index 22d840d..a308060 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -34,12 +34,12 @@ config :logger, :console, format: "[$level] $message\n" config :phoenix, :stacktrace_depth, 20 # Configure your database -config :dwylbot, Dwylbot.Repo, - adapter: Ecto.Adapters.Postgres, - username: "postgres", - password: "postgres", - database: "dwylbot_dev", - hostname: "localhost", - pool_size: 10 +# config :dwylbot, Dwylbot.Repo, +# adapter: Ecto.Adapters.Postgres, +# username: "postgres", +# password: "postgres", +# database: "dwylbot_dev", +# hostname: "localhost", +# pool_size: 10 config :dwylbot, :github_api, DwylbotWeb.GithubAPI.HTTPClient diff --git a/lib/dwylbot.ex b/lib/dwylbot.ex index d58b25b..ae7d0a6 100644 --- a/lib/dwylbot.ex +++ b/lib/dwylbot.ex @@ -1,31 +1,28 @@ defmodule Dwylbot do - use Application - - # See http://elixir-lang.org/docs/stable/elixir/Application.html - # for more information on OTP Applications - def start(_type, _args) do - import Supervisor.Spec - - # Define workers and child supervisors to be supervised - children = [ - # Start the Ecto repository - # supervisor(Dwylbot.Repo, []), - # Start the endpoint when the application starts - supervisor(DwylbotWeb.Endpoint, []), - # Start your own worker by calling: Dwylbot.Worker.start_link(arg1, arg2, arg3) - # worker(Dwylbot.Worker, [arg1, arg2, arg3]), - ] - - # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html - # for other strategies and supported options - opts = [strategy: :one_for_one, name: Dwylbot.Supervisor] - Supervisor.start_link(children, opts) - end + # use Application + # + # # See http://elixir-lang.org/docs/stable/elixir/Application.html + # # for more information on OTP Applications + # def start(_type, _args) do + # import Supervisor.Spec + # + # # Define workers and child supervisors to be supervised + # children = [ + # # Start the Ecto repository + # # supervisor(Dwylbot.Repo, []), + # # Start the endpoint when the application starts + # supervisor(DwylbotWeb.Endpoint, []) + # # Start your own worker by calling: Dwylbot.Worker.start_link(arg1, arg2, arg3) + # # worker(Dwylbot.Worker, [arg1, arg2, arg3]), + # ] + # + # # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html + # # for other strategies and supported options + # opts = [strategy: :one_for_one, name: Dwylbot.Supervisor] + # Supervisor.start_link(children, opts) + # end # Tell Phoenix to update the endpoint configuration # whenever the application is updated. - def config_change(changed, _new, removed) do - DwylbotWeb.Endpoint.config_change(changed, removed) - :ok - end + end diff --git a/lib/dwylbot/application.ex b/lib/dwylbot/application.ex new file mode 100644 index 0000000..ae40eef --- /dev/null +++ b/lib/dwylbot/application.ex @@ -0,0 +1,31 @@ +defmodule Dwylbot.Application do + use Application + + # See http://elixir-lang.org/docs/stable/elixir/Application.html + # for more information on OTP Applications + def start(_type, _args) do + import Supervisor.Spec + + # Define workers and child supervisors to be supervised + children = [ + # Start the Ecto repository + # supervisor(Dwylbot.Repo, []), + # Start the endpoint when the application starts + supervisor(DwylbotWeb.Endpoint, []) + # Start your own worker by calling: Dwylbot.Worker.start_link(arg1, arg2, arg3) + # worker(Dwylbot.Worker, [arg1, arg2, arg3]), + ] + + # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html + # for other strategies and supported options + opts = [strategy: :one_for_one, name: Dwylbot.Supervisor] + Supervisor.start_link(children, opts) + end + + # Tell Phoenix to update the endpoint configuration + # whenever the application is updated. + def config_change(changed, _new, removed) do + DwylbotWeb.Endpoint.config_change(changed, removed) + :ok + end +end diff --git a/lib/dwylbot/repo.ex b/lib/dwylbot/repo.ex deleted file mode 100644 index a70dea7..0000000 --- a/lib/dwylbot/repo.ex +++ /dev/null @@ -1,3 +0,0 @@ -defmodule Dwylbot.Repo do - use Ecto.Repo, otp_app: :dwylbot -end diff --git a/mix.exs b/mix.exs index eb8af38..0407142 100644 --- a/mix.exs +++ b/mix.exs @@ -19,7 +19,7 @@ defmodule Dwylbot.Mixfile do # # Type `mix help compile.app` for more information. def application do - [mod: {Dwylbot, []}, + [mod: {Dwylbot.Application, []}, applications: [:phoenix, :phoenix_pubsub, :phoenix_html, :cowboy, :logger, :gettext, :phoenix_ecto, :postgrex, :httpoison, :joken, :jose]] end