summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/nola/application.ex49
-rw-r--r--lib/web/endpoint.ex40
-rw-r--r--mix.exs42
3 files changed, 68 insertions, 63 deletions
diff --git a/lib/nola/application.ex b/lib/nola/application.ex
index d56d4cb..fc51c2c 100644
--- a/lib/nola/application.ex
+++ b/lib/nola/application.ex
@@ -4,39 +4,41 @@ defmodule Nola.Application do
def start(_type, _args) do
import Supervisor.Spec
- Logger.add_backend(Sentry.LoggerBackend)
-
Nola.Plugins.setup()
:ok = Nola.Matrix.setup()
:ok = Nola.TelegramRoom.setup()
# Define workers and child supervisors to be supervised
- children = [
- supervisor(NolaWeb.Endpoint, []),
- worker(Registry, [[keys: :duplicate, name: Nola.BroadcastRegistry]], id: :registry_broadcast),
- worker(Nola.IcecastAgent, []),
- worker(Nola.Token, []),
- worker(Nola.AuthToken, []),
- Nola.Subnet,
- {GenMagic.Pool, [name: Nola.GenMagic, pool_size: 2]},
- worker(Registry, [[keys: :duplicate, name: Nola.PubSub]], id: :registry_nola_pubsub),
- worker(Nola.Membership, []),
- worker(Nola.Account, []),
- worker(Nola.UserTrack.Storage, []),
- worker(Nola.Plugins.Account, []),
- supervisor(Nola.Plugins.Supervisor, [], [name: Nola.Plugins.Supervisor]),
- ] ++ Nola.Irc.application_childs
- ++ Nola.Matrix.application_childs
+ children =
+ [
+ supervisor(NolaWeb.Endpoint, []),
+ worker(Registry, [[keys: :duplicate, name: Nola.BroadcastRegistry]],
+ id: :registry_broadcast
+ ),
+ worker(Nola.IcecastAgent, []),
+ worker(Nola.Token, []),
+ worker(Nola.AuthToken, []),
+ Nola.Subnet,
+ {GenMagic.Pool, [name: Nola.GenMagic, pool_size: 2]},
+ worker(Registry, [[keys: :duplicate, name: Nola.PubSub]], id: :registry_nola_pubsub),
+ worker(Nola.Membership, []),
+ worker(Nola.Account, []),
+ worker(Nola.UserTrack.Storage, []),
+ worker(Nola.Plugins.Account, []),
+ supervisor(Nola.Plugins.Supervisor, [], name: Nola.Plugins.Supervisor)
+ ] ++
+ Nola.Irc.application_childs() ++
+ Nola.Matrix.application_childs()
opts = [strategy: :one_for_one, name: Nola.Supervisor]
sup = Supervisor.start_link(children, opts)
-
+
start_telegram()
Nola.Plugins.start_all()
- spawn_link(fn() -> Nola.Irc.after_start() end)
- spawn_link(fn() -> Nola.Matrix.after_start() end)
- spawn_link(fn() -> Nola.TelegramRoom.after_start() end)
+ spawn_link(fn -> Nola.Irc.after_start() end)
+ spawn_link(fn -> Nola.Matrix.after_start() end)
+ spawn_link(fn -> Nola.TelegramRoom.after_start() end)
sup
end
@@ -47,11 +49,12 @@ defmodule Nola.Application do
defp start_telegram() do
token = Keyword.get(Application.get_env(:nola, :telegram, []), :key)
+
options = [
username: Keyword.get(Application.get_env(:nola, :telegram, []), :nick, "beauttebot"),
purge: false
]
+
telegram = Telegram.Bot.ChatBot.Supervisor.start_link({Nola.Telegram, token, options})
end
-
end
diff --git a/lib/web/endpoint.ex b/lib/web/endpoint.ex
index a401f54..b54458d 100644
--- a/lib/web/endpoint.ex
+++ b/lib/web/endpoint.ex
@@ -1,49 +1,47 @@
defmodule NolaWeb.Endpoint do
- use Sentry.PlugCapture
use Phoenix.Endpoint, otp_app: :nola
# Serve at "/" the static files from "priv/static" directory.
#
# You should set gzip to true if you are running phoenix.digest
# when deploying your static files in production.
- plug Plug.Static,
- at: "/", from: :nola, gzip: false,
+ plug(Plug.Static,
+ at: "/",
+ from: :nola,
+ gzip: false,
only: ~w(assets css js fonts images favicon.ico robots.txt)
+ )
# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
- if 42==43 && code_reloading? do
- socket "/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket
- plug Phoenix.LiveReloader
- plug Phoenix.CodeReloader
+ if 42 == 43 && code_reloading? do
+ socket("/phoenix/live_reload/socket", Phoenix.LiveReloader.Socket)
+ plug(Phoenix.LiveReloader)
+ plug(Phoenix.CodeReloader)
end
- plug Plug.RequestId
- plug Plug.Logger
+ plug(Plug.RequestId)
+ plug(Plug.Logger)
- plug Plug.Parsers,
+ plug(Plug.Parsers,
parsers: [:urlencoded, :multipart, :json],
pass: ["*/*"],
json_decoder: Jason
+ )
- plug Sentry.PlugContext
- plug Plug.MethodOverride
- plug Plug.Head
+ plug(Plug.MethodOverride)
+ plug(Plug.Head)
- @session_options [store: :cookie,
- key: "_nola_key",
- signing_salt: "+p7K3wrj"]
+ @session_options [store: :cookie, key: "_nola_key", signing_salt: "+p7K3wrj"]
-
- socket "/live", Phoenix.LiveView.Socket,
- websocket: [connect_info: [session: @session_options]]
+ socket("/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]])
# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
- plug Plug.Session, @session_options
+ plug(Plug.Session, @session_options)
- plug NolaWeb.Router
+ plug(NolaWeb.Router)
@doc """
Callback invoked for dynamically configuring the endpoint.
diff --git a/mix.exs b/mix.exs
index 2ff7670..d2fbcea 100644
--- a/mix.exs
+++ b/mix.exs
@@ -6,9 +6,9 @@ defmodule Nola.Mixfile do
app: :nola,
version: version("0.2.7"),
elixir: "~> 1.4",
- elixirc_paths: elixirc_paths(Mix.env),
- compilers: [:phoenix, :gettext] ++ Mix.compilers,
- start_permanent: Mix.env == :prod,
+ elixirc_paths: elixirc_paths(Mix.env()),
+ compilers: [:phoenix, :gettext] ++ Mix.compilers(),
+ start_permanent: Mix.env() == :prod,
deps: deps()
]
end
@@ -21,7 +21,7 @@ defmodule Nola.Mixfile do
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
- defp elixirc_paths(_), do: ["lib"]
+ defp elixirc_paths(_), do: ["lib"]
defp aliases do
[
@@ -69,14 +69,15 @@ defmodule Nola.Mixfile do
{:html_entities, "0.4.0", override: true},
{:file_size, "~> 3.0"},
{:ex2ms, "~> 1.0"},
- {:polyjuice_client, git: "https://git.random.sh/ircbot/polyjuice_client.git", branch: "master", override: true},
- {:matrix_app_service, git: "https://git.random.sh/ircbot/matrix_app_service.ex.git", branch: "master"},
- {:sentry, "~> 8.0.5"},
+ {:polyjuice_client,
+ git: "https://git.random.sh/ircbot/polyjuice_client.git", branch: "master", override: true},
+ {:matrix_app_service,
+ git: "https://git.random.sh/ircbot/matrix_app_service.ex.git", branch: "master"},
{:logger_json, "~> 4.3"},
{:oauth2, "~> 2.0"},
{:powerdnsex, git: "https://git.random.sh/ircbot/powerdnsex.git", branch: "master"},
{:pfx, "~> 0.7.0"},
- {:flake_id, "~> 0.1.0"},
+ {:flake_id, "~> 0.1.0"}
]
end
@@ -84,22 +85,25 @@ defmodule Nola.Mixfile do
{describe, 0} = System.cmd("git", ~w(describe --dirty --broken --all --tags --long))
[_, rest] = String.split(describe, "/", parts: 2)
- info = rest
- |> String.trim()
- |> String.replace("/", "-")
- env = cond do
- Mix.env() == :prod -> ""
- true -> "." <> to_string(Mix.env())
- end
+ info =
+ rest
+ |> String.trim()
+ |> String.replace("/", "-")
- build_timestamp = DateTime.utc_now()
- |> DateTime.to_unix()
- |> to_string()
+ env =
+ cond do
+ Mix.env() == :prod -> ""
+ true -> "." <> to_string(Mix.env())
+ end
+
+ build_timestamp =
+ DateTime.utc_now()
+ |> DateTime.to_unix()
+ |> to_string()
build_date_tag = ".build" <> build_timestamp
v <> "+" <> info <> env <> build_date_tag
end
-
end