fix:优化服务
This commit is contained in:
31
video_worker/scripts/run_wsl_one_click.ps1
Normal file
31
video_worker/scripts/run_wsl_one_click.ps1
Normal file
@@ -0,0 +1,31 @@
|
||||
param(
|
||||
[string]$Distro = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
Set-Location $Root
|
||||
|
||||
if (!(Get-Command wsl -ErrorAction SilentlyContinue)) {
|
||||
throw "WSL command not found. Please install WSL first."
|
||||
}
|
||||
|
||||
# Resolve Windows project path to the same distro that will run the server (mounts differ per distro).
|
||||
if ([string]::IsNullOrWhiteSpace($Distro)) {
|
||||
$linuxPath = (wsl -- wslpath -a "$Root").Trim()
|
||||
} else {
|
||||
$linuxPath = (wsl -d $Distro -- wslpath -a "$Root").Trim()
|
||||
}
|
||||
if ([string]::IsNullOrWhiteSpace($linuxPath)) {
|
||||
throw "Failed to resolve WSL path for project root: $Root"
|
||||
}
|
||||
|
||||
# Single argument to bash -lc; quote the whole string so spaces in path are safe.
|
||||
$bashCommand = "cd '$linuxPath' && chmod +x scripts/one_click_wsl.sh scripts/install_wsl_env.sh scripts/run_server.sh && exec bash scripts/one_click_wsl.sh"
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($Distro)) {
|
||||
wsl -- bash -lc "$bashCommand"
|
||||
} else {
|
||||
wsl -d $Distro -- bash -lc "$bashCommand"
|
||||
}
|
||||
Reference in New Issue
Block a user