summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/nola/application.ex49
-rw-r--r--lib/web/endpoint.ex40
2 files changed, 45 insertions, 44 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.