Starting from version 16.02, ejabberd is packaged as an Hex.pm application: ejabberd on hex.pm. In case of doubt, you can refer to ejabberd official documentation: Embedding ejabberd in an Elixir application
It means that you can now build a customized XMPP messaging platform with Elixir on top of ejabberd. You do so by leveraging ejabberd code base in your app and providing only your custom modules.
This makes the management of your ejabberd plugins easier and cleaner.
To create your own application depending on ejabberd, you can go through the following steps:
- Create new Elixir app with mix:
mix new ejapp * creating README.md * creating .formatter.exs * creating .gitignore * creating mix.exs * creating lib * creating lib/ejapp.ex * creating test * creating test/test_helper.exs * creating test/ejapp_test.exs Your Mix project was created successfully. You can use "mix" to compile it, test it, and more: cd ejapp mix test Run "mix help" for more commands.
- Go to your new app directory:
cd ejapp
- Add the ejabberd package as a dependency in your
mix.exs
file:defmodule Ejapp.Mixfile do ... defp deps do [{:ejabberd, "~> 23.10"}] end end
- Get the default ejabberd configuration file:
mkdir config; wget https://raw.githubusercontent.com/processone/ejabberd/master/ejabberd.yml.example -O config/ejabberd.yml
- Setup some system options in a new file called
config/config.exs
:import Config config :ejabberd, file: "config/ejabberd.yml", log_path: 'logs/ejabberd.log' config :mnesia, dir: 'database/'
- Get the source code of all dependencies and compile them:
mix do deps.get, compile
- Start your app, ejabberd will be started as a dependency:
iex -S mix
- Register an account from Elixir console, later check it was registered:
:ejabberd_auth.try_register("test", "localhost", "passw0rd") :ejabberd_auth.get_users()
-
You are all set, you can now connect with an XMPP client !
Had some challenges during installation on OS X, but then made it work!
https://medium.com/@igorkhomenko/run-ejabberd-as-an-elixir-application-dependency-challenges-80d3cf7d2f13#.fp1q6hjmo
guys, it’s possible to customise ejabberd in this way with Elixir?
Yes, it should be possible to customize ejabberd with module using the hooks. That’s the goal.