Skip to content

Instantly share code, notes, and snippets.

@mazz
Created January 13, 2021 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazz/08b040a1be193df7f58d52910dd7f7f4 to your computer and use it in GitHub Desktop.
Save mazz/08b040a1be193df7f58d52910dd7f7f4 to your computer and use it in GitHub Desktop.
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