Skip to content
Snippets Groups Projects
Commit 989ebf42 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Logging changes.

Refers to #13
parent b6e4ce37
No related branches found
No related tags found
No related merge requests found
...@@ -57,14 +57,12 @@ function Exit-IfDirMissing([string]$DirName, [string]$Desc) { ...@@ -57,14 +57,12 @@ function Exit-IfDirMissing([string]$DirName, [string]$Desc) {
function Stop-MyService { function Stop-MyService {
Write-Host -NoNewLine "Stopping service $($ServiceName): "
try { try {
Stop-Service "$($ServiceName)" -ErrorAction Stop Stop-Service "$($ServiceName)" -ErrorAction Stop
Write-Host "[OK]" -Fore Green Write-Verbose "Stopped service $($ServiceName)."
} }
catch { catch {
$ex = $_.Exception.Message $ex = $_.Exception.Message
Write-Host "[FAILED]" -Fore Red
Send-MailReport -Subject "Shutdown of service $($ServiceName) failed!" ` Send-MailReport -Subject "Shutdown of service $($ServiceName) failed!" `
-Body "Trying to stop the service results in this error:`n$($ex)" -Body "Trying to stop the service results in this error:`n$($ex)"
Exit Exit
...@@ -76,15 +74,12 @@ function Start-MyService { ...@@ -76,15 +74,12 @@ function Start-MyService {
if ((Get-Service $ServiceName).Status -eq "Running") { if ((Get-Service $ServiceName).Status -eq "Running") {
Return Return
} }
Write-Host -NoNewLine "Starting service $($ServiceName): "
try { try {
Start-Service "$($ServiceName)" -ErrorAction Stop Start-Service "$($ServiceName)" -ErrorAction Stop
Write-Host "[OK]" -Fore Green Write-Verbose "Started service $($ServiceName)."
} }
catch { catch {
$ex = $_.Exception.Message $ex = $_.Exception.Message
Write-Host "[FAILED]" -Fore Red
Write-Host $ex
Send-MailReport -Subject "Startup of service $($ServiceName) failed!" ` Send-MailReport -Subject "Startup of service $($ServiceName) failed!" `
-Body "Trying to start the service results in this error:`n$($ex)" -Body "Trying to start the service results in this error:`n$($ex)"
Exit Exit
...@@ -234,7 +229,7 @@ function Update-ServiceBinaries { ...@@ -234,7 +229,7 @@ function Update-ServiceBinaries {
if (Test-Path "$MarkerFile" -Type Leaf) { if (Test-Path "$MarkerFile" -Type Leaf) {
Return Return
} }
Log-Info -Message "No marker file found, trying to update service binaries." Log-Info "Marker file ($($MarkerFile)) missing, trying to update service."
Stop-MyService Stop-MyService
Copy-ServiceFiles Copy-ServiceFiles
New-Item -Type File "$MarkerFile" | Out-Null New-Item -Type File "$MarkerFile" | Out-Null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment