wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.64k stars 321 forks source link

Slow response from Apache, no dynamic changes via environment variable #396

Closed Krzysiaczek closed 2 years ago

Krzysiaczek commented 2 years ago

Hi

I've installed faketime library using apt-get install faketime to test web application. It works but I've got two problems

My config is added to the end of /etc/apache2/envvars

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1
export FAKETIME="2018-12-24 12:41:15"

Or via env variable

export FAKETIME=$FAKETIME

from .env file

FAKETIME="2018-12-24 12:41:15"

through environment option in docker-compose.yml

   environment:
      FAKETIME: ${FAKETIME}
wolfcw commented 2 years ago

Please try to solve this outside of Docker and a web application first by getting familiar with libfaketime's relevant settings in a simpler environment.

You're freezing the time with absolute timestamps, but probably want to use 'start at' dates or offsets/relative dates. Modifying the FAKETIME setting at run-time should work fine. If it's complicated to change an already running process' environment variables, text files and file timestamps can be used for the same purpose. Eventually libfaketime's caching should be disabled.

Krzysiaczek commented 2 years ago

Thanks for the advise. It looks like the 5 sec timeout delay was related to frozen/static clock, adding @ at the beginning of time definition has fixed the problem for me. FAKETIME="@2018-12-24 12:41:15" works as expected.