Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
04bc02d9
Commit
04bc02d9
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Send mails on service shutdown / startup errors.
Refers to
#13
parent
ec144020
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AutoTx-Updater/Update-Service.ps1
+10
-4
10 additions, 4 deletions
AutoTx-Updater/Update-Service.ps1
with
10 additions
and
4 deletions
AutoTx-Updater/Update-Service.ps1
+
10
−
4
View file @
04bc02d9
...
...
@@ -59,11 +59,14 @@ function Exit-IfDirMissing([string]$DirName, [string]$Desc) {
function
Stop-MyService
{
Write-Host
-NoNewLine
"Stopping service
$(
$ServiceName
)
: "
try
{
Stop-Service
$ServiceName
-ErrorAction
Stop
Stop-Service
"
$(
$ServiceName
)
"
-ErrorAction
Stop
Write-Host
"[OK]"
-Fore
Green
}
catch
{
$ex
=
$_
.
Exception
.
Message
Write-Host
"[FAILED]"
-Fore
Red
Send-MailReport
-Subject
"Shutdown of service
$(
$ServiceName
)
failed!"
`
-Body
"Trying to stop the service results in this error:
`n
$(
$ex
)
"
Exit
}
}
...
...
@@ -75,13 +78,16 @@ function Start-MyService {
}
Write-Host
-NoNewLine
"Starting service
$(
$ServiceName
)
: "
try
{
Start-Service
$ServiceName
-ErrorAction
Stop
Start-Service
"
$(
$ServiceName
)
"
-ErrorAction
Stop
Write-Host
"[OK]"
-Fore
Green
}
catch
{
$ex
=
$_
.
Exception
$ex
=
$_
.
Exception
.
Message
Write-Host
"[FAILED]"
-Fore
Red
Write-Host
$ex
.
Message
Write-Host
$ex
Send-MailReport
-Subject
"Startup of service
$(
$ServiceName
)
failed!"
`
-Body
"Trying to start the service results in this error:
`n
$(
$ex
)
"
Exit
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment