Skip to content

Commit

Permalink
Fix install service script.
Browse files Browse the repository at this point in the history
  • Loading branch information
blakerouse committed Jul 23, 2020
1 parent 3811728 commit 06b40e9
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$ErrorActionPreference = "Stop"

# Delete and stop the service if it already exists.
if (Get-Service {{.BeatName}} -ErrorAction SilentlyContinue) {
$service = Get-WmiObject -Class Win32_Service -Filter "name='{{.BeatName}}'"
Expand All @@ -13,8 +15,5 @@ New-Service -name {{.BeatName}} `
-displayName {{.BeatName | title}} `
-binaryPathName "`"$workdir\{{.BeatName}}.exe`" --path.home `"$workdir`" --path.data `"$workdir\data`" run"

# Attempt to set the service to delayed start using sc config.
Try {
Start-Process -FilePath sc.exe -ArgumentList 'config {{.BeatName}} start= delayed-auto'
}
Catch { Write-Host -f red "An error occured setting the service to delayed start." }
# Start the new service.
Start-Service -name {{.BeatName}}

0 comments on commit 06b40e9

Please sign in to comment.