Process logs improvements

This commit is contained in:
Dillon Shook
2024-10-20 22:10:00 -04:00
parent 1912a5b703
commit 159b6ff351
3 changed files with 29 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ COPY ./dockerfiles/goaccess-files/crontab.txt /var/spool/cron/crontabs/root
ENTRYPOINT ["/entrypoint.sh"]
# https://blog.thesparktree.com/cron-in-docker
# source: `docker run --rm -it alpine crond -h`
# -f | Foreground
# -l N | Set log level. Most verbose 0, default 8

View File

@@ -1,12 +1,31 @@
currentDateTime=$(date +"%Y-%m-%dT%H:%M")
for folder in /var/www/logs/*; do
if [ -d "$folder" ]; then
logFile="access.log"
if [ -s "$folder/$logFile" ]; then
rotatedLog="$folder/$currentDateTime.log"
report="$folder/$currentDateTime.html"
if [ -f "$report" ]; then
echo "$report already exists, skipping"
else
echo "Processing $report"
# Manually rotate the log files
cp "$folder/$logFile" $rotatedLog
truncate -s 0 "$folder/$logFile"
goaccess $rotatedLog -a -o "$report" --log-format=COMBINED
gzip $rotatedLog
fi
else
echo "File $folder/$logFile does not exist or is empty"
fi
for file in /var/www/logs/*.log; do
report=${file%.log}.html
if [ -f $report ]; then
echo "$report already exists, skipping"
else
echo "Processing $report"
goaccess $file -a -o $report --log-format=COMBINED
fi
done

View File

@@ -393,7 +393,7 @@ class LoadBalancerManager {
getLogPath(domainName: string) {
// The shared volume path plus a filesafe name
return `/var/log/nginx-shared/${domainName.replace(/\./g, '')}.log`
return `/var/log/nginx-shared/${domainName}/access.log`
}
getInfo() {