UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.36 kB
import{t as isMainModule}from"./is-main-DX3ahFXh.mjs";import{b as resolveGatewayPort,d as parseGatewayPortEnvValue}from"./paths-D_FOvGon.mjs";import{o as readActiveGatewayLockPort}from"./gateway-lock-CQoO1usb.mjs";import{fileURLToPath}from"node:url"; //!src/docker-healthcheck.ts async function readLiveOrEnvPort(){try{const e=await readActiveGatewayLockPort({env:process.env});if(e!==void 0)return e}catch{}return parseGatewayPortEnvValue(process.env.OPENCLAW_GATEWAY_PORT)}async function probeHttp(e){return(await globalThis.fetch(`http://127.0.0.1:${e}/healthz`)).ok}async function probeDockerGatewayHealth(){try{const e=await readLiveOrEnvPort();if(e!==null)try{return await probeHttp(e)}catch{}const{createConfigIO:t}=await import(`./config/config.js`);const n=await t({pluginValidation:`skip`,shellEnvFallback:`defer`}).loadConfigAsync();const r=e??resolveGatewayPort(n,process.env);if(!n.gateway?.tls?.enabled)return e===null&&await probeHttp(r);const{createConfiguredGatewayLocalProbe:i}=await import(`./local-http-probe-BS2ro80A.mjs`);const a=await i(n).requestHttp({host:`127.0.0.1`,port:r,pathname:`/healthz`,timeoutMs:3e3});return a!==null&&a.statusCode>=200&&a.statusCode<300}catch{return false}}if(isMainModule({currentFile:fileURLToPath(import.meta.url)}))probeDockerGatewayHealth().then(e=>{process.exitCode=e?0:1});export{probeDockerGatewayHealth};