processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.07k stars 1.51k forks source link

15.04 undef p1_loglevel #613

Closed joudinet closed 9 years ago

joudinet commented 9 years ago

Hi, While upgrading from 14.07 to 15.04, using the tarball from the github releases (i.e., this is to upgrade the ejabberd version in buildroot), I encounter the following error message when I run ejabberdctl live:

Eshell V6.4  (abort with ^G)

=INFO REPORT==== 1-Jan-1970::00:02:43 ===
    application: ejabberd
    exited: {bad_return,
                {{ejabberd_app,start,[normal,[]]},
                 {'EXIT',
                     {undef,
                         [{p1_loglevel,set,[4],[]},
                          {ejabberd_logger,start,0,
                              [{file,"src/ejabberd_logger.erl"},{line,171}]},
                          {ejabberd_app,start,2,
                              [{file,"src/ejabberd_app.erl"},{line,41}]},
                          {application_master,start_it_old,4,
                              [{file,"application_master.erl"},
                               {line,272}]}]}}}}
    type: temporary
(ejabberd@buildroot)1>

I've read somewhere (sorry I don't find where anymore) that this might be due to a missing lager installation. However, in my case, I do have lager 2.1.1 installed:

# find / -name '*lager*'
/usr/lib/erlang/lib/lager-2.1.1
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_app.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_config.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager.app
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_handler_watcher_sup.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_crash_log.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_default_formatter.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_transform.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_handler_watcher.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_backend_throttle.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_msg.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_file_backend.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_common_test_backend.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_format.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_sup.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_console_backend.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_trunc_io.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_util.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/error_logger_lager_h.beam
/usr/lib/erlang/lib/lager-2.1.1/ebin/lager_stdlib.beam

Any idea what could be the reason of this undef error? Is there any extra dependencies for ejabberd 15.04 than the dependencies of ejabberd 14.07?

cromain commented 9 years ago

if you follow standard build procedure, lager is enabled by default. but maybe you are bypassing some stages with buildroot (i did not checked how you're doing it exactly). Anyway, when compiling ejabberd, you need -DLAGER flag passed to erlc. The error you have is due to lack of this flag at compilation stage. If this breaks your build procedure, you can just patch include/logger.hrl to force -define(LAGER, true).

joudinet commented 9 years ago

Ok, that's strange as I haven't changed the build process since 14.07 and I do see lager=true in config.log. So, from the rebar.config.script, it does looks like it should define LAGER in the erl_opts. Anyway, I'll investigate in that direction. Thanks for your help.

zinid commented 9 years ago

@joudinet try to clean sources and re-run autogen.sh

joudinet commented 9 years ago

I've cleaned all sources, and re-run autoconf. I've also added '-vvvvvvvv' to rebar options to see what variables are defined. Unfortunately, rebar does not give me this information. It just shows

DEBUG: Evaluating config script "/home/johan/Documents/buildroot/output/build/ejabberd-15.04/rebar.config.script"

Otherwise, I see that vars.config does contain '{lager, true}.' Any idea how to see if -DLAGER flag is given to erlc?

joudinet commented 9 years ago

Another thing that I do not understand (probably because I don't know Erlang) is how p1_loglevel could be defined by the lager package even though there is no such function in lager sources. Browsing sources of lager v2.1.1, I could find get_loglevel and set_loglevel only. However, p1_loglevel does appear in the p1_logger project, which is installed only if lagger=false. Anyway, this was exactly the same in 14.07, which compiles and run fine in my environment, so that's just for my curiosity.

cromain commented 9 years ago

p1_loglevel is not defined by lagger, it's called by ejabberd_logger when compiled without LAGER flag. as you have lager enabled, your build does not contains p1_loglevel module so you get that undef EXIT message. I don't understand why ejabberd_logger is not compiled with LAGER flag as your rebar seems configured correctly. you can force rebuild ejabberd_logger like this, but i don't know how to force rebar to show the compilation command. erlc -I include -o ebin -DLAGER src/ejabberd_logger.erl

cromain commented 9 years ago

by the way, as you're working on a new package, you'd better look at 15.06.

joudinet commented 9 years ago

I've just patched include/logger.hrl to force -define(LAGER, true). (the line before the -ifdef(LAGER).) Still, I get the same error message :-\ I'm going to rebuild from scratch with 15.06 to see if I have any better luck than with 15.04.

mremond commented 9 years ago

Not sure what you are doing, but you do not need patching. You probably have seriously broken you build chain.

joudinet commented 9 years ago

@mremond: Indeed, patching include/logger.hrl is not needed as it results to the same runtime error. However, as I'm cross-compiling ejabberd, I do need to apply several patches to the sources. I successfully did it for ejabberd-14.07 few months ago (cf. https://blog.process-one.net/ejabberd-available-as-a-buildroot-package/) but I have some extra difficulties to do it with the newer ejabberd versions.

Nevertheless, I may have found the reason why it fails to build with lager support: Looking at the result of ejabberd:module_info().:

ejabberd:module_info().
[{exports,[{start,0},
           {stop,0},
           {get_pid_file,0},
           {start_app,1},
           {start_app,2},
           {check_app,1},
           {module_info,0},
           {module_info,1}]},
 {imports,[]},
 {attributes,[{vsn,[258849252322980351772256115980582497905]},
              {author,['alexey@process-one.net']},
              {protocol,[{xep,4,'2.9'}]},
              {protocol,[{xep,86,'1.0'}]},
              {protocol,[{xep,106,'1.1'}]},
              {protocol,[{xep,170,'1.0'}]},
              {protocol,[{xep,205,'1.0'}]},
              {protocol,[{xep,212,'1.0'}]},
              {protocol,[{xep,216,'1.0'}]},
              {protocol,[{xep,243,'1.0'}]},
              {protocol,[{xep,270,'1.0'}]}]},
 {compile,[{options,[{outdir,"ebin"},
                     {src_dirs,[asn1,src]},
                     {i,"include"},
                     {i,"/home/johan/Documents/buildroot/output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/share/rebar/deps"}]},
           {version,"5.0.4"},
           {time,{2015,6,26,9,32,10}},
           {source,"/home/johan/Documents/buildroot/output/build/ejabberd-15.06/src/ejabberd.erl"}]}]

It looks like the options provided by ejabberd-15.06/rebar.config.script are missing. Instead of using the rebar binary provided by ejabberd, I use the one provided by buildroot (v2.5.1). I also set ERL_COMPILER_OPTIONS environment variable to include the directory where I download dependencies. I wonder if in such case, rebar might ignore the erl_opts defined by rebar.config.script. Note that it works fine with ejabberd-14.07. I'll try to recompile with the latest rebar release available (v2.6.0), then I'll investigate how rebar handles both the ERL_COMPILER_OPTIONS environment variable and the erl_opts variable in rebar.config.

joudinet commented 9 years ago

Well well, I've started again the migration from 14.07 to 15.06 from scratch. This time, instead of upgrading every ejabberd dependency, I simply reuse the same versions as the ones for 14.07. Surprisingly, this time ejabberd 15.06 starts without complaining, and I do see {d, 'LAGER'} in the compile options when I run ejabberd:module_info(). So, I guess the problem originated from an incompatible version of one the many ejabberd dependency. As I'd like to use the last versions, I'm going to investigate it further but at least I can close this issue now. Thanks for your help.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.