prosody/prosody-docker

log output does not make it to the console

Closed this issue · 3 comments

I’m using the following config:

log = {
        -- All goes to stdout:
        { levels = { "debug" }; to = "console";  };
}

However, when running prosody, all I see is:

# docker run -p 5222:5222 -p 5269:5269 -e PASSWORD=<redacted> --read-only --volume /media/persistent/prosody/etc:/etc/prosody:ro --volume /media/persistent/prosody/lib:/var/lib/prosody prosody/prosody
general             error   The version of LuaExpat on your system does not support stanza size limits, which may leave servers on untrusted networks (e.g. the internet) vulnerable to denial-of-service attacks. You should upgrade to LuaExpat 1.3.0 or higher as soon as possible. See http://prosody.im/doc/depends#luaexpat for more information.
The given hostname does not exist in the config

Only when prosody fails to start, I see more messages:

# docker run -p 5222:5222 -p 5269:5269 -e PASSWORD=<redacted> --read-only --volume /media/persistent/prosody/etc:/etc/prosody:ro --volume /media/persistent/prosody/lib:/var/lib/prosody prosody/prosody                   
general             error   The version of LuaExpat on your system does not support stanza size limits, which may leave servers on untrusted networks (e.g. the internet) vulnerable to denial-of-service attacks. You should upgrade to LuaExpat 1.3.0 or higher as soon as possible. See http://prosody.im/doc/depends#luaexpat for more information.
The given hostname does not exist in the config
general             info    Hello and welcome to Prosody version 0.9.8
general             info    Prosody is using the select backend for connection handling
portmanager         info    Activated service 's2s' on [::]:5269, [*]:5269
portmanager         info    Activated service 'c2s' on [::]:5222, [*]:5222
portmanager         info    Activated service 'legacy_ssl' on no ports
general             info    Shutting down: Couldn't write pidfile
general             info    Shutting down...
general             info    Shutdown status: Cleaning up
general             info    Shutdown complete
general             error   The version of LuaExpat on your system does not support stanza size limits, which may leave servers on untrusted networks (e.g. the internet) vulnerable to denial-of-service attacks. You should upgrade to LuaExpat 1.3.0 or higher as soon as possible. See http://prosody.im/doc/depends#luaexpat for more information.

It might be enough to fix #21 (build a more recent docker image) to address this, but I’m not entirely sure — I figured I’d report it regardless.

I think this might just be due to buffering. After a couple of minutes, I got a bunch of log messages, but they’re cut off in the middle of the last line.

Could it be that prosody or prosodyctl doesn’t realize they are in fact outputting to a tty?

Prosody just writes to stdout like pretty much any application. It's usually line-buffered, but perhaps docker is doing something weird.

You can try setting the environment variable __FLUSH_LOG to make Prosody force a flush after every line.

Using -e __FLUSH_LOG=1 on the docker invocation does help indeed, thanks!

FWIW, moby/moby#1385 is related, and I think the ideal solution would be to just call setvbuf to advise the C stdlib that the output should be line-buffered.

I’m not saying we need another option in prosody for that, though, given the minimal differences between letting the C stdlib do line-buffering and just flushing after each line.