Skip to content

Commit

Permalink
FIx a typo and finally have a strategy for killing web service (#99)
Browse files Browse the repository at this point in the history
* Fix win_tests.ps1 typo

Missing comma

* Use taskkill.exe to kill the entire process tree

This makes appStop irrelevant for teardown, as the entire tree is terminated by an OS provided utility
  • Loading branch information
borrrden authored Nov 25, 2024
1 parent 0ac0550 commit 8f73a07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 5 additions & 5 deletions jenkins/pipelines/java/webservice/win_teardown.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ param (
$ErrorActionPreference = "Stop"
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Microsoft\jdk-17.0.13.11-hotspot")

$cblVersion = "${version}-${buildNumber}"
# $cblVersion = "${version}-${buildNumber}"

Write-Host "Windows Web Service: Shutdown the Test Server"
Push-Location servers\jak\webservice
& .\gradlew.bat --no-daemon appStop -PcblVersion="${cblVersion}"
Pop-Location
# Write-Host "Windows Web Service: Shutdown the Test Server"
# Push-Location servers\jak\webservice
# & .\gradlew.bat --no-daemon appStop -PcblVersion="${cblVersion}"
# Pop-Location

Write-Host "Windows Web Service: Shutdown the environment"
Push-Location environment
Expand Down
9 changes: 3 additions & 6 deletions jenkins/pipelines/java/webservice/win_tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ try
{
$temp = New-TemporaryFile
Write-Host "Windows Web Service: Build and start the Test Server"
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue app\build server.log, app\server.url
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue app\build, server.log, app\server.url
$app = Start-Process .\gradlew.bat -ArgumentList "--no-daemon jettyStart -PcblVersion=${cblVersion}" -PassThru -WindowStyle Hidden -RedirectStandardInput $temp -RedirectStandardOutput server.log -RedirectStandardError server.err
Write-Host "Windows Web Service: Server started: $($app.ProcessName), $($app.Id)"
Pop-Location
Expand Down Expand Up @@ -96,13 +96,10 @@ finally

if ( $null -ne $app )
{
Write-Host "Windows Web Service: Stopping process $($app.ProcessName), $($app.Id)"
Stop-Process $app
Write-Host "Windows Web Service: Stopping process tree $($app.ProcessName), $($app.Id)"
taskkill.exe /f /t /PID $($app.Id)
}

Write-Host "Windows Web Service: Stopping the server"
& .\gradlew.bat --no-daemon appStop -PcblVersion="${cblVersion}"

Write-Host "Windows Web Service: Exiting"
Exit $status
}

0 comments on commit 8f73a07

Please sign in to comment.