Moved wDayzManager logs rotation.

Moved wDayzManager logs rotation from servers start loop to outside.
This commit is contained in:
2024-12-15 13:15:19 +03:00
parent 4b3817e2ec
commit 65c58da0f2

View File

@@ -1,4 +1,4 @@
# wDayzManager v0.1 # wDayzManager v0.2
# Copyright (c) 2024 Vladislav Salikov aka W0LF aka 'dreamforce' # Copyright (c) 2024 Vladislav Salikov aka W0LF aka 'dreamforce'
# https://github.com/dreamforceinc # https://github.com/dreamforceinc
# Required module: PSIni # Required module: PSIni
@@ -226,6 +226,17 @@ if ($rotateLogs) {
$daysAmount = [Math]::Abs($config.daysAmount) $daysAmount = [Math]::Abs($config.daysAmount)
if (-not ([string]::IsNullOrEmpty($config.rotatedLogsFolderName))) { if (-not ([string]::IsNullOrEmpty($config.rotatedLogsFolderName))) {
$rotatedLogsFolderName = $config.rotatedLogsFolderName $rotatedLogsFolderName = $config.rotatedLogsFolderName
Write-Host "Removing old wDayzManager logs..."
$fileList = $null
$fileList = Get-ChildItem -Path $currentPath\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.AddDays( -3) }
# Write-Host $fileList -Separator "`n"
foreach ($file in $fileList) {
Remove-Item -Path $file
Write-Host "Removed $($file)!"
}
Write-Host "Total: $($fileList.Count)"
Write-Host
} }
else { else {
Write-Error "The 'rotatedLogsFolderName' parameter not set!" Write-Error "The 'rotatedLogsFolderName' parameter not set!"
@@ -436,20 +447,6 @@ foreach ($srv in $servers) {
Write-Host Write-Host
} }
#endregion #endregion
#region ### wDayzManager ###
Write-Host "Removing old wDayzManager logs..."
$fileList = $null
$fileList = Get-ChildItem -Path $currentPath\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.AddDays( -3) }
# Write-Host $fileList -Separator "`n"
foreach ($file in $fileList) {
Remove-Item -Path $file
Write-Host "Removed $($file)!"
}
Write-Host "Total: $($fileList.Count)"
Write-Host
#endregion
} }
# Write-Host " instance: $($instance)" # Write-Host " instance: $($instance)"