Ortus-Solutions / docker-commandbox

Official CommandBox Docker Image for ColdFusion/CFML/Java applications
62 stars 41 forks source link

Log tailing disappears when rotated #40

Closed mjclemente closed 4 years ago

mjclemente commented 4 years ago

We're seeing logging within containers disappear after a period of time. That is, logging is fine when the container is deployed, but disappears at some point during the following days.

We believe this is because CommandBox rotates the log files every 10MB or so, but the tail continues to follow the old file. We can reproduce this on development looping over systemOutput to fill up the log file:

image

Currently, the tail command in this image's run.ish looks like this:

tail -n 500 -f $( echo $(box server info property=consoleLogPath) | xargs )

That is, it's using a lowercase -f. Based on my local testing, if we switch to an uppercase -F, tail will pickup the changed file and continue to work even after the log file is rotated.

For reference, there are a few Stack posts that discuss this:

https://serverfault.com/questions/53699/continuously-monitor-logs-with-tail-that-are-occasionally-rotated https://unix.stackexchange.com/questions/22698/how-to-do-a-tail-f-of-log-rotated-files

mjclemente commented 4 years ago

@jclausen Sorry for the bother, not trying to be a nuisance. Just wanted to see if I could get your thoughts on this, when you have the chance. Thanks!

jclausen commented 4 years ago

No problem. Thanks for bumping this. In the short-term I will fix this by bumping the case on the ‘-F’ . Long-term, we have a few options that might help. Number one, though is getting Docker not to exit when we start with the ‘—console’ flag up - hence the reason we tail the physical log file.

Look for a fresh build tomorrow AM

jclausen commented 4 years ago

Also hot-patched to master branch with commit #b6ec66 . Will be available after build #254 completes: https://travis-ci.org/Ortus-Solutions/docker-commandbox/builds/657722597

mjclemente commented 4 years ago

Thanks! 🎉