Add support for custom modules
This commit is contained in:
parent
7722e5a67a
commit
48ae3c4347
4 changed files with 28 additions and 0 deletions
|
|
@ -32,6 +32,7 @@ defmodule Pleroma.Application do
|
|||
def start(_type, _args) do
|
||||
Pleroma.Config.DeprecationWarnings.warn()
|
||||
setup_instrumenters()
|
||||
load_custom_modules()
|
||||
|
||||
# Define workers and child supervisors to be supervised
|
||||
children =
|
||||
|
|
@ -67,6 +68,29 @@ defmodule Pleroma.Application do
|
|||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
|
||||
def load_custom_modules() do
|
||||
dir = Pleroma.Config.get([:instance, :custom_modules_dir])
|
||||
|
||||
if dir && File.exists?(dir) do
|
||||
dir
|
||||
|> File.ls!()
|
||||
|> Enum.map(&Path.join(dir, &1))
|
||||
|> Kernel.ParallelCompiler.compile()
|
||||
|> case do
|
||||
{:error, _errors, _warnings} ->
|
||||
raise "Invalid custom modules"
|
||||
|
||||
{:ok, modules, _warnings} ->
|
||||
Enum.each(modules, fn mod ->
|
||||
name = mod |> Atom.to_string() |> String.trim_leading("Elixir.")
|
||||
IO.puts("Custom module loaded: #{name}")
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp setup_instrumenters do
|
||||
require Prometheus.Registry
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue