merge: updates from tracking
All checks were successful
continuous-integration/drone/pr Build is passing
All checks were successful
continuous-integration/drone/pr Build is passing
This commit is contained in:
@@ -1,35 +1,26 @@
|
||||
defmodule Wabanex.Application do
|
||||
# See https://hexdocs.pm/elixir/Application.html
|
||||
# for more information on OTP Applications
|
||||
@moduledoc false
|
||||
|
||||
use Application
|
||||
|
||||
def start(_type, _args) do
|
||||
children = [
|
||||
# Start the PromEx supervisor
|
||||
Wabanex.PromEx,
|
||||
# Start the Ecto repository
|
||||
Wabanex.Repo,
|
||||
# Start the Telemetry supervisor
|
||||
WabanexWeb.Telemetry,
|
||||
# Start the PubSub system
|
||||
{Phoenix.PubSub, name: Wabanex.PubSub},
|
||||
# Start the Endpoint (http/https)
|
||||
WabanexWeb.Endpoint,
|
||||
# Start a worker by calling: Wabanex.Worker.start_link(arg)
|
||||
# {Wabanex.Worker, arg}
|
||||
{Growth.Indicators.Load, []}
|
||||
{Growth.Indicators.Load, []},
|
||||
{DNSCluster,
|
||||
query: Application.get_env(:wabanex, :dns_cluster_query) || :ignore,
|
||||
log: :info,
|
||||
resolver: Application.get_env(:wabanex, :dns_cluster_resolver) || DNSCluster.Resolver},
|
||||
WabanexWeb.Endpoint
|
||||
]
|
||||
|
||||
# See https://hexdocs.pm/elixir/Supervisor.html
|
||||
# for other strategies and supported options
|
||||
opts = [strategy: :one_for_one, name: Wabanex.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
|
||||
WabanexWeb.Endpoint.config_change(changed, removed)
|
||||
:ok
|
||||
|
26
lib/wabanex/dev_dns_cluster_resolver.ex
Normal file
26
lib/wabanex/dev_dns_cluster_resolver.ex
Normal file
@@ -0,0 +1,26 @@
|
||||
defmodule Wabanex.DevDNSClusterResolver do
|
||||
@moduledoc """
|
||||
Local DNS resolver for cluster query.
|
||||
"""
|
||||
require Record
|
||||
|
||||
Record.defrecord(:hostent, Record.extract(:hostent, from_lib: "kernel/include/inet.hrl"))
|
||||
|
||||
def basename(node_name) when is_atom(node_name) do
|
||||
[basename, _] = node_name |> to_string() |> String.split("@")
|
||||
basename
|
||||
end
|
||||
|
||||
def connect_node(node_name) when is_atom(node_name) do
|
||||
Node.connect(node_name)
|
||||
end
|
||||
|
||||
def list_nodes, do: Node.list(:visible)
|
||||
|
||||
def lookup(query, type) when is_binary(query) and type in [:a, :aaaa] do
|
||||
case :inet_res.getbyname(~c"#{query}", type) do
|
||||
{:ok, hostent(h_addr_list: addr_list)} -> addr_list
|
||||
{:error, _} -> []
|
||||
end
|
||||
end
|
||||
end
|
28
lib/wabanex/release.ex
Normal file
28
lib/wabanex/release.ex
Normal file
@@ -0,0 +1,28 @@
|
||||
defmodule Wabanex.Release do
|
||||
@moduledoc """
|
||||
Used for executing DB release tasks when run in production without Mix
|
||||
installed.
|
||||
"""
|
||||
@app :wabanex
|
||||
|
||||
def migrate do
|
||||
load_app()
|
||||
|
||||
for repo <- repos() do
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true))
|
||||
end
|
||||
end
|
||||
|
||||
def rollback(repo, version) do
|
||||
load_app()
|
||||
{:ok, _, _} = Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :down, to: version))
|
||||
end
|
||||
|
||||
defp repos do
|
||||
Application.fetch_env!(@app, :ecto_repos)
|
||||
end
|
||||
|
||||
defp load_app do
|
||||
Application.load(@app)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user