-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Update Remove Finch VM step to only shutdown if required (#1182)
* ci: Update Remove Finch VM step Signed-off-by: Subash Kotha <[email protected]> * ci: Shutdown only if there are running distributions Signed-off-by: Subash Kotha <[email protected]> * ci: Create and reuse script to clean up WSL Signed-off-by: Subash Kotha <[email protected]> --------- Signed-off-by: Subash Kotha <[email protected]> Co-authored-by: Subash Kotha <[email protected]>
- Loading branch information
1 parent
3a81c08
commit f85dc03
Showing
3 changed files
with
40 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# We want these cleanup commands to always run, ignore errors so the step completes. | ||
$ErrorActionPreference = 'Ignore' | ||
|
||
taskkill /f /im wslservice.exe 2> nul || cmd /c "exit /b 0" | ||
sc query LxssManager | findstr "STATE" | findstr /C:"STOPPED" > nul && net start LxssManager | ||
wsl --list --verbose --all | ||
|
||
# Attempt to shut down WSL if any distribution is running | ||
if (wsl --list --verbose | findstr /C:"Running" > nul) { | ||
timeout 60s wsl --shutdown | ||
# Forcefully kill WSL if still running | ||
if (Get-Process -Name "wsl" -ErrorAction SilentlyContinue) { | ||
Stop-Process -Name "wsl" -Force | ||
} | ||
echo "WSL has been shut down successfully." | ||
} | ||
|
||
# Unregister 'lima-finch' distribution if it exists | ||
if (wsl --list --quiet | findstr /C:"lima-finch" > nul) { | ||
wsl --unregister lima-finch | ||
echo "'lima-finch' has been unregistered successfully." | ||
} | ||
|
||
wsl --list --verbose --all | ||
Remove-Item C:\Users\Administrator\AppData\Local\.finch -Recurse |