Skip to content

Commit 97f0e85

Browse files
committed
fix some issue
1 parent e7fecbb commit 97f0e85

File tree

2 files changed

+35
-41
lines changed

2 files changed

+35
-41
lines changed

_go-irl.ps1

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,23 @@ try {
4040
[string[]]$Arguments
4141
)
4242

43-
while ($true) {
44-
if (-not (Test-Path -Path $Command -PathType Leaf)) {
45-
Write-Host "[Manager] ERROR: Binary for '$Name' not found at the expected path: '$Command'." -ForegroundColor Red
46-
throw "Required binary '$Command' not found."
47-
}
48-
49-
Write-Host "[Manager] Starting '$Name' with arguments: $($Arguments -join ' ')" -ForegroundColor Cyan
50-
51-
& $Command $Arguments *>&1 | ForEach-Object {
52-
$timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
53-
Write-Host "[$Name`:$timestamp] $_"
54-
}
55-
56-
$exitCode = $LASTEXITCODE
43+
if (-not (Test-Path -Path $Command -PathType Leaf)) {
44+
Write-Host "[Manager] ERROR: Binary for '$Name' not found at the expected path: '$Command'." -ForegroundColor Red
45+
throw "Required binary '$Command' not found."
46+
}
5747

58-
Write-Host "[Manager] Process '$Name' exited with code $exitCode. Restarting in 5 seconds..." -ForegroundColor Yellow
59-
Start-Sleep -Seconds 5
48+
Write-Host "[Manager] Starting '$Name' with arguments: $($Arguments -join ' ')" -ForegroundColor Cyan
49+
50+
& $Command $Arguments *>&1 | ForEach-Object {
51+
$timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
52+
Write-Host "[$Name`:$timestamp] $_"
6053
}
54+
55+
$exitCode = $LASTEXITCODE
56+
57+
Write-Host "[Manager] Process '$Name' exited with code $exitCode." -ForegroundColor Yellow
6158
}
6259

63-
# ASCII Art
6460
@"
6561
6662
@@ -88,8 +84,7 @@ try {
8884
StartAndMonitor -Name "obs-srt-bridge" -Command $using:OBS_SRT_BRIDGE_BIN -Arguments $using:OBS_SRT_BRIDGE_ARGS
8985
}
9086

91-
92-
while ($true) {
87+
while ($jobs | Where-Object { $_.State -eq 'Running' }) {
9388
$jobs | ForEach-Object {
9489
$output = Receive-Job -Job $_
9590
if ($output) {
@@ -98,6 +93,8 @@ try {
9893
}
9994
Start-Sleep -Milliseconds 200
10095
}
96+
97+
$jobs | Receive-Job | ForEach-Object { Write-Host $_ }
10198
}
10299
finally {
103100
Get-Job | Stop-Job -Force

go-irl.sh

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,28 @@ start_and_monitor() {
5353
shift
5454
local cmd_and_args=("$@")
5555

56-
while true; do
57-
if [ ! -x "${cmd_and_args[0]}" ]; then
58-
echo -e "[Manager] ERROR: Binary for '$name' not found or not executable at '${cmd_and_args[0]}'.
59-
Please ensure the binary exists and has execute permissions (e.g., 'chmod +x ${cmd_and_args[0]}').
60-
You can download the latest pre-built binary from: https://github.com/e04/$name/releases/"
61-
return 1
62-
fi
56+
if [ ! -x "${cmd_and_args[0]}" ]; then
57+
echo -e "[Manager] ERROR: Binary for '$name' not found or not executable at '${cmd_and_args[0]}'.
58+
Please ensure the binary exists and has execute permissions (e.g., 'chmod +x ${cmd_and_args[0]}').
59+
You can download the latest pre-built binary from: https://github.com/e04/$name/releases/"
60+
return 1
61+
fi
6362

64-
echo "[Manager] Starting '$name'..."
65-
66-
"${cmd_and_args[@]}" 2>&1 | while IFS= read -r line || [ -n "$line" ]; do
67-
printf '[%s:%s] %s\n' "$name" "$(date +'%Y-%m-%d %H:%M:%S')" "$line"
68-
done
69-
70-
exit_code=${PIPESTATUS[0]}
71-
72-
if [ "$exit_code" -eq 137 ]; then
73-
echo "[Manager] Process '$name' was killed (SIGKILL). Shutting down manager and child processes."
74-
kill -TERM "$PPID" 2>/dev/null
75-
exit 1
76-
fi
63+
echo "[Manager] Starting '$name'..."
7764

78-
echo "[Manager] Process '$name' exited with code ${exit_code}. Restarting in 5 seconds..."
79-
sleep 5
65+
"${cmd_and_args[@]}" 2>&1 | while IFS= read -r line || [ -n "$line" ]; do
66+
printf '[%s:%s] %s\n' "$name" "$(date +'%Y-%m-%d %H:%M:%S')" "$line"
8067
done
68+
69+
exit_code=${PIPESTATUS[0]}
70+
71+
if [ "$exit_code" -eq 137 ]; then
72+
echo "[Manager] Process '$name' was killed (SIGKILL). Shutting down manager and child processes."
73+
kill -TERM "$PPID" 2>/dev/null
74+
exit 1
75+
fi
76+
77+
echo "[Manager] Process '$name' exited with code ${exit_code}."
8178
}
8279

8380
# --- Main Execution ---

0 commit comments

Comments
 (0)