feat: add docker-compose deployment and harden gateway startup
- add docker-compose setup with hermes-agent + hermes-webui - make runtime config env-driven (compose vars + HERMES_BIN) - improve gateway startup/restart resilience in docker - make base image configurable via BASE_IMAGE/HERMES_AGENT_IMAGE Closes https://github.com/EKKOLearnAI/hermes-web-ui/issues/14
This commit is contained in:
@@ -268,6 +268,17 @@ async function ensureApiServerConfig() {
|
||||
|
||||
async function ensureGatewayRunning() {
|
||||
const upstream = config.upstream.replace(/\/$/, '')
|
||||
const waitForGatewayReady = async (timeoutMs: number = 15000) => {
|
||||
const deadline = Date.now() + timeoutMs
|
||||
while (Date.now() < deadline) {
|
||||
try {
|
||||
const res = await fetch(`${upstream}/health`, { signal: AbortSignal.timeout(2000) })
|
||||
if (res.ok) return true
|
||||
} catch { }
|
||||
await new Promise(r => setTimeout(r, 300))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch(`${upstream}/health`, { signal: AbortSignal.timeout(5000) })
|
||||
@@ -279,16 +290,14 @@ async function ensureGatewayRunning() {
|
||||
try {
|
||||
// 👉 关键:保存 PID
|
||||
gatewayPid = await startGatewayBackground()
|
||||
|
||||
await new Promise(r => setTimeout(r, 3000))
|
||||
|
||||
const res = await fetch(`${upstream}/health`, { signal: AbortSignal.timeout(5000) })
|
||||
if (res.ok) {
|
||||
if (await waitForGatewayReady()) {
|
||||
console.log(`✓ Gateway started (PID: ${gatewayPid})`)
|
||||
} else {
|
||||
console.error('gateway start failed: timed out waiting for health')
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error('gateway start failed:', err.message)
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap()
|
||||
bootstrap()
|
||||
|
||||
Reference in New Issue
Block a user