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
ef210f24
Commit
ef210f24
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Make Stop-MyService log a message, depending on the service state.
parent
c8614b14
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AutoTx-Updater/Update-Service.ps1
+8
-5
8 additions, 5 deletions
AutoTx-Updater/Update-Service.ps1
with
8 additions
and
5 deletions
AutoTx-Updater/Update-Service.ps1
+
8
−
5
View file @
ef210f24
...
...
@@ -70,8 +70,13 @@ function Get-LastLogLines([string]$Path, [int]$Count) {
}
function
Stop-MyService
{
function
Stop-MyService
([
string
]
$Message
)
{
if
((
Get-Service
$ServiceName
)
.
Status
-eq
"Stopped"
)
{
Log-Info
"
$(
$Message
)
(Service already in state 'Stopped')"
Return
}
try
{
Log-Info
"
$(
$Message
)
Attempting service
$(
$ServiceName
)
shutdown..."
Stop-Service
"
$(
$ServiceName
)
"
-ErrorAction
Stop
Write-Verbose
"Stopped service
$(
$ServiceName
)
."
}
...
...
@@ -186,8 +191,7 @@ function Update-File {
Return
$False
}
Log
-Info
"Found newer file at
$(
$SrcFile
)
, updating..."
Stop
-MyService
Stop
-MyService
"Found newer file at
$(
$SrcFile
)
, updating..."
try
{
Create-Backup
-FileName
$DstFile
...
...
@@ -228,6 +232,7 @@ function Copy-ServiceFiles {
Where-Object
{
$_
-match
$Pattern
}
|
Sort-Object
|
Select-Object
-Last
1
Stop-MyService
"Trying to update service using package [
$(
$PkgDir
)
]."
Write-Verbose
"Update source package:
$(
$PkgDir
)
"
Copy-Item
-Recurse
-Force
-ErrorAction
Stop
`
-Path
"
$(
$UpdateBinariesPath
)
\
$(
$PkgDir
)
\
$(
$ServiceName
)
\*"
`
...
...
@@ -247,8 +252,6 @@ function Update-ServiceBinaries {
Write-Verbose
"Found marker [
$(
$MarkerFile
)
], not updating service."
Return
$False
}
Log
-Info
"Marker file (
$(
$MarkerFile
)
) missing, trying to update service."
Stop
-MyService
Copy
-ServiceFiles
try
{
New-Item
-Type
File
"
$MarkerFile
"
-ErrorAction
Stop
|
Out-Null
...
...
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