///
import { ExposedPort, HealthCheck } from '@nosana/sdk';
import Dockerode from 'dockerode';
import EventEmitter from 'events';
/**
* `restart_on_failure` and `max_restarts` ship in the @nosana/sdk release that
* accompanies this change; widening the SDK type here keeps the node building
* against an SDK that predates them.
*/
export type RestartableHealthCheck = HealthCheck & {
restart_on_failure?: boolean;
max_restarts?: number;
};
export declare class ExposedPortHealthCheck {
private exposedPortMap;
private frpcContainer;
private containerName;
private startupIntervalMs;
private continuousIntervalMs;
/**
* Tracks job previous state to show change in state of job mainly when going from failed to success.
*/
private healthStatus;
private jobEmitter;
private intervals;
/**
* Restarts the container in place. Set only when an exposed port declares a
* `restart_on_failure` check; without it a failure is reported and no more.
*/
private restartContainer?;
/** Health-triggered restarts so far, counted across every exposed port. */
private restartCount;
private restartInFlight;
private restartLimitLogged;
private stopped;
private readonly connectTimeoutSeconds;
private readonly startupMaxTimeSeconds;
private readonly continuousMaxTimeSeconds;
private flowId;
constructor(flowId: string, frpcContainer: Dockerode.Container, jobEmitter: EventEmitter, containerName: string, restartContainer?: () => Promise, startupIntervalMs?: number, continuousIntervalMs?: number);
addExposedPortsMap(exposedPortMap: Map): void;
/**
* A continuous pass only covers checks up to the first non-continuous one, so
* a liveness probe that isn't continuous, or that sits behind a startup-only
* check, never runs. Say so rather than let `restart_on_failure` look active
* while doing nothing.
*/
private reportUnreachableRestartChecks;
startServiceExposedUrlHealthCheck(): void;
private startStartupHealthCheck;
private startContinuousHealthCheck;
/**
* Restart the container behind a failed liveness probe.
*
* The restart is container-wide even though the probe belongs to one port, so
* every port drops back to startup probing and reports itself online again as
* it starts answering — the same path a first start takes.
*/
private restartUnhealthyContainer;
stopHealthCheckForId(id: string): void;
stopAllHealthChecks(): void;
private checkPortHealth;
private runHttpHealthCheck;
private runWebSocketHealthCheck;
private execCommand;
}