mirror of
https://github.com/actions/runner-images.git
synced 2026-01-08 11:30:49 +08:00
[Windows] Unify services handling (#8871)
* [Windows] Unify services handling * Fix Set-Service usage
This commit is contained in:
committed by
GitHub
parent
6efbc46fc7
commit
79c347765a
@@ -105,10 +105,10 @@ $servicesToDisable = @(
|
||||
'gupdate'
|
||||
'gupdatem'
|
||||
'StorSvc'
|
||||
)
|
||||
|
||||
$servicesToDisable | Stop-SvcWithErrHandling
|
||||
$servicesToDisable | Set-SvcWithErrHandling -Arguments @{StartupType = "Disabled"}
|
||||
) | Get-Service -ErrorAction SilentlyContinue
|
||||
Stop-Service $servicesToDisable
|
||||
$servicesToDisable.WaitForStatus('Stopped', "00:01:00")
|
||||
$servicesToDisable | Set-Service -StartupType Disabled
|
||||
|
||||
# Disable scheduled tasks
|
||||
$allTasksInTaskPath = @(
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
################################################################################
|
||||
|
||||
# Stop w3svc service
|
||||
Stop-Service -Name w3svc | Out-Null
|
||||
Stop-Service -Name w3svc
|
||||
|
||||
# Install latest apache in chocolatey
|
||||
$installDir = "C:\tools"
|
||||
@@ -12,10 +12,10 @@ Install-ChocoPackage apache-httpd -ArgumentList "--force", "--params", "/install
|
||||
|
||||
# Stop and disable Apache service
|
||||
Stop-Service -Name Apache
|
||||
Set-Service Apache -StartupType Disabled
|
||||
Set-Service -Name Apache -StartupType Disabled
|
||||
|
||||
# Start w3svc service
|
||||
Start-Service -Name w3svc | Out-Null
|
||||
Start-Service -Name w3svc
|
||||
|
||||
# Invoke Pester Tests
|
||||
Invoke-PesterTests -TestFile "Apache"
|
||||
|
||||
@@ -12,9 +12,10 @@ Install-Binary `
|
||||
Write-Host "Adding the firewall rule for Google update blocking..."
|
||||
New-NetFirewallRule -DisplayName "BlockGoogleUpdate" -Direction Outbound -Action Block -Program "C:\Program Files (x86)\Google\Update\GoogleUpdate.exe"
|
||||
|
||||
$GoogleSvcs = ('gupdate','gupdatem')
|
||||
$GoogleSvcs | Stop-SvcWithErrHandling -StopOnError
|
||||
$GoogleSvcs | Set-SvcWithErrHandling -Arguments @{StartupType = "Disabled"}
|
||||
$googleServices = @('gupdate', 'gupdatem') | Get-Service
|
||||
Stop-Service $googleServices
|
||||
$googleServices.WaitForStatus('Stopped', "00:01:00")
|
||||
$googleServices | Set-Service -StartupType Disabled
|
||||
|
||||
$regGoogleUpdatePath = "HKLM:\SOFTWARE\Policies\Google\Update"
|
||||
$regGoogleUpdateChrome = "HKLM:\SOFTWARE\Policies\Google\Chrome"
|
||||
|
||||
@@ -26,17 +26,16 @@ Install-Binary `
|
||||
-ExpectedSignature (Get-ToolsetContent).mongodb.signature
|
||||
|
||||
# Add mongodb to the PATH
|
||||
$mongodbService = "mongodb"
|
||||
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE '$mongodbService'").PathName
|
||||
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'mongodb'").PathName
|
||||
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
|
||||
Add-MachinePathItem "$mongoBin"
|
||||
|
||||
# Wait for mongodb service running
|
||||
$svc = Get-Service $mongodbService
|
||||
$svc.WaitForStatus('Running','00:01:00')
|
||||
$mongodbService = Get-Service "mongodb"
|
||||
$mongodbService.WaitForStatus('Running', '00:01:00')
|
||||
|
||||
# Stop and disable mongodb service
|
||||
Stop-Service -Name $mongodbService
|
||||
Set-Service $mongodbService -StartupType Disabled
|
||||
Stop-Service $mongodbService
|
||||
$mongodbService | Set-Service -StartupType Disabled
|
||||
|
||||
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
################################################################################
|
||||
|
||||
# Stop w3svc service
|
||||
Stop-Service -Name w3svc | Out-Null
|
||||
Stop-Service -Name w3svc
|
||||
|
||||
# Install latest nginx in chocolatey
|
||||
$installDir = "C:\tools"
|
||||
@@ -12,10 +12,10 @@ Install-ChocoPackage nginx -ArgumentList "--force", "--params", "/installLocatio
|
||||
|
||||
# Stop and disable Nginx service
|
||||
Stop-Service -Name nginx
|
||||
Set-Service nginx -StartupType Disabled
|
||||
Set-Service -Name nginx -StartupType Disabled
|
||||
|
||||
# Start w3svc service
|
||||
Start-Service -Name w3svc | Out-Null
|
||||
Start-Service -Name w3svc
|
||||
|
||||
# Invoke Pester Tests
|
||||
Invoke-PesterTests -TestFile "Nginx"
|
||||
|
||||
@@ -78,7 +78,7 @@ if ($exitCode -ne 0) {
|
||||
|
||||
# Stop and disable PostgreSQL service
|
||||
$pgService = Get-Service -Name postgresql*
|
||||
Stop-Service -InputObject $pgService
|
||||
Set-Service -InputObject $pgService -StartupType Disabled
|
||||
Stop-Service $pgService
|
||||
$pgService | Set-Service -StartupType Disabled
|
||||
|
||||
Invoke-PesterTests -TestFile "Databases" -TestName "PostgreSQL"
|
||||
|
||||
Reference in New Issue
Block a user