Progress exposing reports

This commit is contained in:
Dillon Shook
2024-10-21 09:05:11 -04:00
parent 159b6ff351
commit 5315f7ffb9
5 changed files with 40 additions and 24 deletions

View File

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

View File

@@ -702,7 +702,8 @@ class CaptainManager {
hostPath: CaptainConstants.nginxLogsVolumeName,
volumeName:
CaptainConstants.nginxLogsVolumeName,
containerPath: '/var/www/logs',
containerPath:
CaptainConstants.nginxSharedLogsPath,
mode: 'rw',
},
],

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}/access.log`
return `${CaptainConstants.nginxSharedLogsPath}/${domainName}-access.log`
}
getInfo() {
@@ -452,6 +452,7 @@ class LoadBalancerManager {
const registryDomain = `${
CaptainConstants.registrySubDomain
}.${dataStore.getRootDomain()}`
const logAccess = dataStore.getGoAccessInfo().isEnabled
let hasRootSsl = false
@@ -503,6 +504,9 @@ class LoadBalancerManager {
CaptainConstants.nginxStaticRootDir +
CaptainConstants.nginxDomainSpecificHtmlDir
}/${captainDomain}`,
logAccessPath: logAccess
? CaptainConstants.nginxSharedLogsPath
: undefined,
},
registry: {
crtPath: self.getSslCertPath(registryDomain),
@@ -811,7 +815,7 @@ class LoadBalancerManager {
},
{
volumeName: CaptainConstants.nginxLogsVolumeName,
containerPath: '/var/log/nginx-shared',
containerPath: CaptainConstants.nginxSharedLogsPath,
},
],
[CaptainConstants.captainNetworkName],

View File

@@ -107,6 +107,8 @@ const data = {
nginxDefaultHtmlDir: '/default',
nginxSharedLogsPath: '/var/log/nginx-shared',
letsEncryptEtcPathOnNginx: '/letencrypt/etc',
nginxDomainSpecificHtmlDir: '/domains',

View File

@@ -108,6 +108,18 @@
proxy_read_timeout 120s;
}
<%
if (captain.logAccessPath) {
%>
location /goaccess {
alias <%-captain.logAccessPath%>;
autoindex on;
}
<%
}
%>
# Used by Lets Encrypt
location /.well-known/acme-challenge/ {
root <%-captain.staticWebRoot%>;