mrDoctorWho/ejabberd_mod_apns

Error when trying to start ejabberd after installing mod_apns

Closed this issue · 3 comments

I have a similar issues with the one from here: other issue

I am using ejabberd-16.08 on Mac OS
Here are the steps I do to add the custom module into ejabberd:

  • Put the module into ejabberd/src folder.
  • In terminal run the command:

$ ./erlc -I ejabberd/include mod_apns.erl

  • It results in the the following output in the terminal windows:
mod_apns.erl:8: can't find include file "ejabberd.hrl"
mod_apns.erl:9: can't find include file "logger.hrl"
mod_apns.erl:10: can't find include file "jlib.hrl"
mod_apns.erl:36: undefined macro 'DEBUG/2'
mod_apns.erl:85: undefined macro 'DEBUG/2'
mod_apns.erl:138: undefined macro 'DEBUG/2'
mod_apns.erl:160: undefined macro 'INFO_MSG/2'
mod_apns.erl:18: function iq/3 undefined
mod_apns.erl:18: function message/3 undefined
mod_apns.erl:18: function start/2 undefined
mod_apns.erl:12: Warning: undefined callback function depends/2 (behaviour 'gen_mod')
mod_apns.erl:14: Warning: record apns_users is unused
mod_apns.erl:69: Warning: function create_json/2 is unused
mod_apns.erl:72: Warning: function create_keyvalue/1 is unused
mod_apns.erl:77: Warning: function create_pair/1 is unused
mod_apns.erl:79: Warning: function add_quotes/1 is unused 
  • Add the module into config file at /etc/ejabberd/ejabberd.yml
mod_apns:
  address: "gateway.push.apple.com"
  port: 2195
  certfile: "cert.pem"
  keyfile: "key.pem"
  • ejabbeerd could not be started. The log file ejabberd.log displays: "Problem starting the module mod_apns for host ..."
2016-09-14 16:12:22.125 [critical] <0.38.0>@gen_mod:start_module:162 Problem starting the module mod_apns for host <<"macbook.local">> 
 options: [{address,<<"gateway.push.apple.com">>},
           {port,2195},
           {certfile,<<"cert.pem">>},
           {keyfile,<<"key.pem">>}]
 error: undef
[{mod_apns,start,
           [<<"macbook.local">>,
            [{address,<<"gateway.push.apple.com">>},
             {port,2195},
             {certfile,<<"cert.pem">>},
             {keyfile,<<"key.pem">>}]],
           []},
 {gen_mod,start_module,3,[{file,"src/gen_mod.erl"},{line,154}]},
 {lists,foreach,2,[{file,"lists.erl"},{line,1337}]},
 {ejabberd_app,start,2,[{file,"src/ejabberd_app.erl"},{line,76}]},
 {application_master,start_it_old,4,
                     [{file,"application_master.erl"},{line,273}]}]
2016-09-14 16:12:22.125 [critical] <0.38.0>@gen_mod:maybe_halt_ejabberd:170 ejabberd initialization was aborted because a module start failed.

  • I tried to add the code from bellow to the mod_apns.erl but have no luck with it.
-ifndef(LAGER).
-define(LAGER, 1).
-endif.

Do you have any suggestion? Any help is appreciated.

Hi @apphipster
The second commend on the issue you provided and the README says that you must compile the module with ejabberd itself.

I managed to compile the module using the following command:
(Attention: the path varies depending on the installed ejabberd version)
$ bin/erlc -I lib/ejabberd-16.08/include/ -I deps/ -pa lib/ejabberd-16.08/ebin src/mod_apns.erl
One warning is displayed:
src/mod_apns.erl:12: Warning: undefined callback function depends/2 (behaviour 'gen_mod')
Add the module into config file at /etc/ejabberd/ejabberd.yml
Restart ejabberd.

In the file jeabberd.log there is an entry:
2016-09-26 12:43:39.575 [info] <0.6670.0>@mod_apns:start:154 mod_apns Has started successfully!

You can also check the presence of the module using the link:
http://localhost:5280/admin/server/macbook.local/node/ejabberd@localhost/modules/
(replace "macbook.local" with your domain)

Closing due to inactivity.