If you’re working to embed ejabberd into a Phoenix app, I hope this helps!
I had been following the docs and tutorial (note that the blog post is dated):
https://docs.ejabberd.im/developer/extending-ejabberd/elixir/
https://blog.process-one.net/embedding-ejabberd-into-an-elixir-phoenix-web-application/
I’m using the following versions:
- Phoenix 1.4.10
- ejabberd 19.8
If you’re having Logger/logger/lager issues, see this related thread: https://elixirforum.com/t/getting-ejabberd-to-use-elixir-logger-in-release-build/24252
I had been getting an error on compilation (see below). The solution was to remove the ejabberd dependency from mix.exs
, clean out the build, get and compile the other dependencies, then add back ejabberd before a final compilation step. Here’s the full workaround:
# Clean out build; careful with rm -rf ...
rm -rf _build
rm -rf deps
mix deps.clean --all
# In mix.exs, comment out the line in deps {:ejabberd, "~> 19.8"},
mix do deps.get, compile
# In mix.exs, uncomment the ejabberd line in deps
mix do deps.get, compile
Does anyone know why building everything at once causes this task to crash? I’d like to find a better solution. Thanks!
...
==> phoenix_ecto
Compiling 6 files (.ex)
Generated phoenix_ecto app
16:32:04.624 [info] Application phoenix exited: exited in: Phoenix.start(:normal, [])
** (EXIT) exited in: :gen_server.call(:telemetry_handler_table, {:insert, {Phoenix.Logger, [:phoenix, :channel_handled_in]}, [[:phoenix, :channel_handled_in]], #Function<8.17735610/4 in Phoenix.Logger.install/0>, :ok})
** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
16:32:04.624 [info] Application eex exited: :stopped
** (MatchError) no match of right hand side value: {:error, {:phoenix, {:bad_return, {{Phoenix, :start, [:normal, []]}, {:EXIT, {:noproc, {:gen_server, :call, [:telemetry_handler_table, {:insert, {Phoenix.Logger, [:phoenix, :channel_handled_in]}, [[:phoenix, :channel_handled_in]], #Function<8.17735610/4 in Phoenix.Logger.install/0>, :ok}]}}}}}}}
(phoenix) lib/mix/tasks/compile.phoenix.ex:11: Mix.Tasks.Compile.Phoenix.run/1
(mix) lib/mix/task.ex:331: Mix.Task.run_task/3
(mix) lib/mix/tasks/compile.all.ex:73: Mix.Tasks.Compile.All.run_compiler/2
(mix) lib/mix/tasks/compile.all.ex:53: Mix.Tasks.Compile.All.do_compile/4
(mix) lib/mix/tasks/compile.all.ex:24: anonymous fn/1 in Mix.Tasks.Compile.All.run/1
(mix) lib/mix/tasks/compile.all.ex:40: Mix.Tasks.Compile.All.with_logger_app/1
(mix) lib/mix/task.ex:331: Mix.Task.run_task/3
(mix) lib/mix/tasks/compile.ex:96: Mix.Tasks.Compile.run/1
(mix) lib/mix/task.ex:331: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2
(elixir) lib/code.ex:813: Code.require_file/2
In any case, I hope this workaround helps someone out there!