znc / znc-docker

https://hub.docker.com/_/znc/
51 stars 29 forks source link

Avoid needlessly running znc-buildmod at every startup #17

Closed mokou closed 1 year ago

mokou commented 6 years ago

Closes #16

DarthGandalf commented 6 years ago
  1. Run ZNC
  2. Put a new module to modules/
  3. Run ZNC
  4. Wonder why the new module was not built

Rebuilding should be skipped only if there are no new modules.

mokou commented 6 years ago

Ah, is that the intention? I thought it was just to prevent ZNC from crashing at launch on an update.

DarthGandalf commented 6 years ago

To pick up new modules automaticaly? Yes, it's intended. Otherwise, adding modules would require writing a custom Dockerfile with something like this (pseudocode)

FROM znc
COPY foo.cpp
RUN znc-buildmod foo.cpp

It's still possible to do it this way with autobuilding modules, but not required.

I thought your reason for #16 is to optimize startup time in the common case when no modules were added. And that is a good optimization... Just not as implemented in this PR.

DarthGandalf commented 6 years ago

Note that znc-buildmod doesn't prevent crash on startup after upgrade:

  1. Add foo.cpp to modules/
  2. Run ZNC, so that foo.so is built
  3. Remove foo.cpp from modules/
  4. Upgrade
  5. Run ZNC. It won't rebuild foo.so because there's no source. So it would still be module version mismatch.

Fortunately, ZNC doesn't crash on module version mismatch, because it compares version number of module and of itself, and a couple of other things before actually loading the module. See https://github.com/znc/znc/blob/2f4b158fd1d1c03eee5f73777bcb55b0d6c535b5/src/Modules.cpp#L1958-L1977 It's still possible to make it crash while loading a bad module, but not in the common case.

mokou commented 6 years ago

Right, that's the exact scenario that caused my ZNC to fail to start on the recent update from 1.7 to 1.7.1, so I'm not sure if that works for all modules. Either way I'll make the changes to this tomorrow.