Skip to content

Instantly share code, notes, and snippets.

@mazz
Created Jan 13, 2021
Embed
What would you like to do?
defmodule Markably.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
alias Markably.Accounts.Invitations
require Logger
def start(_type, _args) do
Invitations.enable()
Logger.info("Invitations.enabled?: #{Invitations.enabled?}")
children = [
# Start the Ecto repository
Markably.Repo,
# Start the Telemetry supervisor
MarkablyWeb.Telemetry,
# Start the PubSub system
{Phoenix.PubSub, name: Markably.PubSub},
# Start the Endpoint (http/https)
MarkablyWeb.Endpoint,
{Oban, oban_config()},
Markably.EtsKeyValue
# Start a worker by calling: Markably.Worker.start_link(arg)
# {Markably.Worker, arg}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Markably.Supervisor]
Supervisor.start_link(children, opts)
end
# Conditionally disable crontab, queues, or plugins here.
defp oban_config do
opts = Application.get_env(:markably, Oban)
if Code.ensure_loaded?(IEx) and IEx.started?() do
opts
|> Keyword.put(:crontab, false)
|> Keyword.put(:queues, false)
else
opts
end
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
MarkablyWeb.Endpoint.config_change(changed, removed)
:ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment