INNER CODE UNIT · TypeScript
handleStopUnlocked
lidge-jun/opencodex · src/cli/index.ts:1038
async function handleStopUnlocked(snapshot?: GuardedStopSnapshot) {
// The receipt must name the endpoint the owner was stopping — an obligation nobody can
// locate cannot be proven discharged. Only the runtime record knows it; a proxy started
// with an explicit --port is not on the configured one.
const endpointOf = (runtime: { port: number; hostname?: string } | null): { hostname: string; port: number } | null =>
runtime?.port ? { hostname: runtime.hostname ?? "127.0.0.1", port: runtime.port } : null;
// Last-resort endpoint for a receipt: the address this home is configured to serve on,
// which is what a later recovery probe would ask about anyway.
const configuredEndpoint = (): { hostname: string; port: number } => {
try {
const config = loadConfig();
return {
hostname: config.hostname ?? "127.0.0.1",
port: typeof config.port === "number" && config.port > 0 ? config.port : 10100,
};
} catch {
return { hostname: "127.0.0.1", port: 10100 };
}