0

I'm trying to figure out how to properly setup an ejabberd project that allows for easy compilation of custom beam files- so far, we've been using an existing project that is cumbersome to manage, and uses erlide as the IDE.

I would like to set up the project in a way that I can use a more helpful IDE like vscode, and somehow streamline the compiling and copying of the beam files and updating the module on the server.

Writing code in Elixir is fine as well- I just want the project to be set up in a way that is dev friendly.

Apologies if the question is too broad, but I'm not exactly sure how else to best phrase it. If you feel like I'm missing something in my current flow, please let me know, as I've basically inherited this project. If there are any clarifications required, let me know as well.

Thanks.

Athena
  • 155
  • 7

1 Answers1

0

easy compilation of custom beam files

somehow streamline the compiling and copying of the beam files and updating the module on the server.

If the task is about compiling and loading additional modules, a running ejabberd node can compile, load and start additional modules in runtime, see https://docs.ejabberd.im/developer/extending-ejabberd/modules/#ejabberd-contrib

Usually the modules come from https://github.com/processone/ejabberd-contrib but you can tell ejabberd to download other modules from other git repositories, or you can copy modules source code and tell ejabberd to install them. And those modules can be written in Erlang or Elixir. Full example: https://docs.ejabberd.im/developer/extending-ejabberd/elixir/#elixir-module-in-ejabberd-contrib

Basically:

  1. you write the module in your development machine, test it...
  2. when happy with the source code, copy mod_whatever.erl to the production machine, $HOME/.ejabberd-modules/sources/mod_whatever as explained in the example mentioned earlier
  3. run ejabberdctl module_install mod_whatever

In step 2, instead of copying the source code yourself, you can have a git repository just for your module, tell ejabberd the module's git URL, similarly to https://github.com/processone/ejabberd-contrib/tree/master/extra

BTW, for step 3, starting in ejabberd 22.10, there's a page in ejabberd webadmin to install and uninstall those modules (copying the files requires manual administration of course).

I would like to set up the project in a way that I can use a more helpful IDE like vscode

What a coincidence, these days I'm playing with VSCode variants (VSCode, VSCodium, Coder's code-server and Github Codespaces) and how to develop ejabberd using them. This is useful for step 1 that I mentioned earlier (write module and test it). If you are interested in ejabberd + VSCode, tell me.

Badlop
  • 3,840
  • 1
  • 8
  • 9
  • Completely forgot about my post here. I think I've kind of figured out the compiling part with your help- I'll have to set it up on my local, but I'm getting the hang of it in codespaces. Another question, and this is a real pain point- debugging. Tried understanding this answer- https://stackoverflow.com/a/31646953/5779146 , but I don't quite understand where the components are located (debugger and wx). Any insight? – Athena Jan 03 '23 at 04:19
  • I don't quite understand what Mickael means by, "just copied those two dir"- where are these components exactly? – Athena Jan 03 '23 at 04:37
  • 1
    If you are using Codespaces or any other VSCode variant, look at https://docs.ejabberd.im/developer/vscode/ and use ejabberd from git master. The ErlangLS extension in VSCode provides debugger support – Badlop Jan 03 '23 at 11:18
  • Does the ErlangLS extension also respect breakpoints and inspect variables? Because I can't quite seem to get it to work. – Athena Jan 04 '23 at 11:31