ejabberd 15.11 MAC os custom module error[fixed]

i follow document to create custom module by below step

1.

-module(mod_hello_world).

-behaviour(gen_mod).

%% Required by ?INFO_MSG macros
-include("logger.hrl").

%% gen_mod API callbacks
-export([start/2, stop/1]).

start(_Host, _Opts) ->
    ?INFO_MSG("Hello, ejabberd world!", []),
    ok.

stop(_Host) ->
    ?INFO_MSG("Bye bye, ejabberd world!", []),
    ok.

2. move the mod_hello_world.beam to /Application/ejabberd-15.11/lib/ejabberd-15.11/ebin/

3.add mod_hello_world to ejabberd.yml file

4. start ejabberd server, after start , it tell me error occur, below is my log


2015-12-22 18:30:42.592 [critical] <0.37.0>@gen_mod:start_module:106 Problem starting the module mod_hello_world for host <<"siuming-mbp">>
options: []
error: undef
[{p1_logger,info_msg,[mod_hello_world,12,"Hello, ejabberd world!",[]],[]},
{mod_hello_world,start,2,
[{file,"/Applications/ejabberd-15.11/lib/ejabberd-15.11/include/mod_hello_world.erl"},
{line,12}]},
{gen_mod,start_module,3,[{file,"src/gen_mod.erl"},{line,98}]},
{lists,foreach,2,[{file,"lists.erl"},{line,1336}]},
{ejabberd_app,start,2,[{file,"src/ejabberd_app.erl"},{line,73}]},
{application_master,start_it_old,4,
[{file,"application_master.erl"},{line,272}]}]
2015-12-22 18:30:42.592 [critical] <0.37.0>@gen_mod:start_module:111 ejabberd initialization was aborted because a module start failed.

i fixed this issue. 1. put

i fixed this issue.

1. put the module to /Application/ejabberd-15.11/lib/ejabberd-15.11/include
2. open the terminal
3.cd /Application/ejabberd-15.11/bin
4.
./erlc -DLAGER=true -I ../lib/ejabberd-15.11/include ../lib/ejabberd-15.11/include/mod_hello_world.erl

5.
put mod_hello_world.beam to /Application/ejabberd-15.11/lib/ejabberd-15.11/ebin

Here are steps to add your

Here are steps to add your custom module into ejabberd

- put your module into ejabberd/src folder.
- come to ejabberd directory in terminal and run command $ sudo make
- it will show you that your module is compiled. Now run $ sudo make install
- Add your module into config file at /etc/ejabberd/ejabberd.yml
- restart your ejabberd and your custom module will be running. You will see your msg in ejabberd log.

ejabberd will take care of the .erl and .beam file on its own.

Syndicate content