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
43677b84
Commit
43677b84
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Don't require the service to run upfront, remember its state instead.
And only start the service eventually if it was running before.
parent
3be78eff
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
Updater/Update-Service.ps1
+13
-15
13 additions, 15 deletions
Updater/Update-Service.ps1
with
13 additions
and
15 deletions
Updater/Update-Service.ps1
+
13
−
15
View file @
43677b84
...
@@ -14,25 +14,19 @@ Param(
...
@@ -14,25 +14,19 @@ Param(
### function definitions #####################################################
### function definitions #####################################################
function
Ensure-ServiceRunning
([
string
]
$ServiceName
)
{
function
ServiceIsRunning
([
string
]
$ServiceName
)
{
$Continue
=
$True
try
{
try
{
$Service
=
Get-Service
$ServiceName
-ErrorAction
Stop
$Service
=
Get-Service
$ServiceName
-ErrorAction
Stop
if
(
$Service
.
Status
-ne
"Running"
)
{
if
(
$Service
.
Status
-ne
"Running"
)
{
Write-Host
"Service
$(
$ServiceName
)
is not running."
Log-Debug
"Service
$(
$ServiceName
)
is not running."
$Continue
=
$False
Return
$False
}
}
}
}
catch
{
catch
{
Write-Host
$_
.
Exception
.
Message
Log-Error
"Error checking service state:
$(
$_
.
Exception
.
Message
)
"
$Continue
=
$False
Exit
}
if
(
$Continue
)
{
Log-Debug
"Prerequisites okay, service is running."
Return
}
}
Log-Error
"ERROR: Service '
$(
$ServiceName
)
' must be installed and running."
Return
$True
Exit
}
}
...
@@ -414,7 +408,7 @@ Log-Debug "$($Me) started..."
...
@@ -414,7 +408,7 @@ Log-Debug "$($Me) started..."
# first check if the service is installed and running at all
# first check if the service is installed and running at all
Ensure
-
ServiceRunning
$ServiceName
$ServiceRunningBefore
=
Service
Is
Running
$ServiceName
$UpdPathConfig
=
"
$(
$UpdateSourcePath
)
\Configs\
$(
$
env
:
COMPUTERNAME
)
"
$UpdPathConfig
=
"
$(
$UpdateSourcePath
)
\Configs\
$(
$
env
:
COMPUTERNAME
)
"
$UpdPathConfigCommon
=
"
$(
$UpdateSourcePath
)
\Configs\_COMMON_"
$UpdPathConfigCommon
=
"
$(
$UpdateSourcePath
)
\Configs\_COMMON_"
...
@@ -449,8 +443,12 @@ if ($ServiceUpdated) {
...
@@ -449,8 +443,12 @@ if ($ServiceUpdated) {
}
}
if
(
$msg
-ne
""
)
{
if
(
$msg
-ne
""
)
{
Log-Debug
"Update action occurred, finishing up..."
if
(
$ServiceRunningBefore
)
{
Start-MyService
Log-Debug
"Update action occurred, finishing up..."
Start-MyService
}
else
{
Log-Debug
"Not starting the service as it was not running before."
}
Send-MailReport
-Subject
"Config and / or service has been updated!"
`
Send-MailReport
-Subject
"Config and / or service has been updated!"
`
-Body
$msg
-Body
$msg
}
else
{
}
else
{
...
...
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