签出用反了
parent
4c316db5b9
commit
4539e352a5
|
|
@ -102,17 +102,11 @@ jobs:
|
||||||
|
|
||||||
- name: npm run electron (auto-exit after 30min)
|
- name: npm run electron (auto-exit after 30min)
|
||||||
run: |
|
run: |
|
||||||
echo "======================================================================";
|
|
||||||
echo "cd packages/gui";
|
|
||||||
echo "--------------------";
|
|
||||||
cd packages/gui;
|
|
||||||
dir || ls -lah;
|
|
||||||
|
|
||||||
echo "======================================================================";
|
echo "======================================================================";
|
||||||
echo "npm run electron with timeout";
|
echo "npm run electron with timeout";
|
||||||
echo "--------------------";
|
echo "--------------------";
|
||||||
if [ "$RUNNER_OS" = "Windows" ]; then
|
if [ "$RUNNER_OS" = "Windows" ]; then
|
||||||
powershell ../../scripts/run-electron-with-timeout.ps1
|
powershell _script/run-electron-with-timeout.ps1
|
||||||
else
|
else
|
||||||
bash ../../scripts/run-electron-with-timeout.sh
|
bash _script/run-electron-with-timeout.sh
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ while ($timer.Elapsed.TotalSeconds -lt $TimeoutSeconds) {
|
||||||
Write-Host "❌ 程序运行不正常"
|
Write-Host "❌ 程序运行不正常"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
Start-Sleep -Seconds 1
|
Start-Sleep -Seconds 60
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$process.HasExited) {
|
if (!$process.HasExited) {
|
||||||
|
|
@ -1,43 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
import { spawn } from 'node:child_process'
|
|
||||||
import path from 'node:path'
|
|
||||||
|
|
||||||
const timeoutMs = Number(process.env.ELECTRON_TIMEOUT_MS ?? 30 * 60 * 1000) // 30 minutes
|
|
||||||
const workdir = path.resolve(process.argv[2] ?? 'packages/gui')
|
|
||||||
const command = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
|
||||||
|
|
||||||
console.log(`Starting npm run electron in ${workdir} with ${timeoutMs / 60000} minute timeout...`)
|
|
||||||
|
|
||||||
const child = spawn(command, ['run', 'electron'], {
|
|
||||||
cwd: workdir,
|
|
||||||
stdio: 'inherit',
|
|
||||||
})
|
|
||||||
|
|
||||||
let timedOut = false
|
|
||||||
|
|
||||||
const timer = setTimeout(() => {
|
|
||||||
timedOut = true
|
|
||||||
console.log(`\n⏱ Electron run completed ${timeoutMs / 60000} minutes without error, terminating...`)
|
|
||||||
child.kill('SIGTERM')
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!child.killed)
|
|
||||||
child.kill('SIGKILL')
|
|
||||||
}, 5000)
|
|
||||||
}, timeoutMs)
|
|
||||||
|
|
||||||
child.on('exit', (code, signal) => {
|
|
||||||
clearTimeout(timer)
|
|
||||||
if (timedOut) {
|
|
||||||
console.log('✅ 程序运行正常')
|
|
||||||
process.exit(0)
|
|
||||||
} else {
|
|
||||||
console.log('❌ 程序运行不正常')
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
child.on('error', (err) => {
|
|
||||||
clearTimeout(timer)
|
|
||||||
console.error('Failed to start electron:', err)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
Loading…
Reference in New Issue