import { BehaviorSubject } from 'rxjs';
import { EndpointContext, Taon__NS__createContextTemplate } from 'taon/lib-prod';
import { BaseCliWorkerConfig } from './base-cli-worker-config';
import type { TaonBaseCliWorkerController } from './base-cli-worker-controller';
import { BaseCliWorkerTerminalUI } from './base-cli-worker-terminal-ui';
import { BaseCliMethodOptions } from './base-cli-worker.models';
export interface BaseCliWorkerGuiUrlOptions {
    domain?: string;
    port?: number | null;
    useHttps?: boolean;
}
export declare abstract class BaseCliWorker<REMOTE_CTRL extends TaonBaseCliWorkerController<any>, TERMINAL_UI extends BaseCliWorkerTerminalUI<any> = any> {
    /**
     * unique id for service
     */
    readonly serviceID: string;
    /**
     * external command that will start service
     */
    readonly startCommandFn: () => string;
    /**
     * unique id for service
     */
    readonly serviceVersion: string;
    /**
     * Indicates if worker is part of cloud
     * and should use cloud ip address
     */
    static readonly isCloudEnable: Pick<BehaviorSubject<boolean>, 'next' | 'getValue'>;
    /**
     * Cloud ip address of the worker (if part of cloud)
     */
    static readonly cloudIp: Pick<BehaviorSubject<string | null>, 'next' | 'getValue'>;
    private static workers;
    readonly SPECIAL_WORKER_READY_MESSAGE = "$$$ WORKER_READY $$$";
    /**
     * dependency workers that should be started before this worker
     */
    readonly dependencyWorkers: Map<string, BaseCliWorker<any, any>>;
    readonly terminalUI: TERMINAL_UI;
    readonly workerContextTemplate: ReturnType<typeof Taon__NS__createContextTemplate>;
    /**
     * Name of the worker context
     */
    get contextName(): string;
    /**
     * Port where worker is running
     * (getter only accessible from host machine)
     */
    get port(): number | undefined;
    getWorkerInfoGuiUrl(options?: BaseCliWorkerGuiUrlOptions): string;
    readonly controllerClass: new () => REMOTE_CTRL;
    constructor(
    /**
     * unique id for service
     */
    serviceID: string, 
    /**
     * external command that will start service
     */
    startCommandFn: () => string, 
    /**
     * unique id for service
     */
    serviceVersion: string);
    static getAllWorkersStartedInSystemFromCurrentCli(): BaseCliWorker<any, any>[];
    get processLocalInfoObj(): BaseCliWorkerConfig;
    getRemoteControllerFor<ctrl = REMOTE_CTRL>(options?: {
        methodOptions: Partial<BaseCliMethodOptions>;
        /**
         * Optionally get other controller from remote context
         */
        controllerClass?: new () => ctrl;
    }): Promise<ctrl>;
    /**
     * stop if started
     */
    kill(options?: {
        reason?: string;
        skipDependencies?: boolean;
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<void>;
    /**
     * kill detached process and start again
     * @param options.detached - default true
     */
    restart(options?: {
        methodOptions?: BaseCliMethodOptions;
    }): Promise<void>;
    /**
     * only for cli start
     * @param cliParams on from cli
     */
    cliStartProcedure(options: {
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<{
        controller: REMOTE_CTRL;
        worker: BaseCliWorker<any, any>;
        serviceId: string;
    }>;
    protected getRemoteContextFor(options?: {
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<EndpointContext>;
    protected get pathToProcessLocalInfoJson(): string;
    protected get processLocalInfoPortNotInited(): boolean;
    protected get workerIsStarting(): boolean;
    protected startDetachedIfNeedsToBeStarted(options?: {
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<void>;
    /**
     * <strong>IMPORTANT USE ONLY IN DEVELOPMENT !!!</strong>
     * for production use startDetachedIfNeedsToBeStarted()
     * start normally process
     * this will crash if process already started
     */
    protected startNormallyInCurrentProcess(options?: {
        methodOptions?: Partial<BaseCliMethodOptions>;
        actionBeforeTerminalUI?: () => Promise<void>;
    }): Promise<void>;
    protected preventStartIfAlreadyStarted(options?: {
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<void>;
    protected killWorkerWithLowerVersion(options?: {
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<void>;
    /**
     * This has 2 purposes:
     * - infinite check when when detached process finished starting
     * - quick check if service is healthy / already started
     */
    protected isServiceHealthy(options: {
        healthCheckRequestTrys?: number;
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<boolean>;
    /**
     * start if not started detached process
     */
    protected startDetached(options?: {
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<void>;
    private saveProcessInfo;
    protected initializeWorkerMetadata(options?: {
        methodOptions?: Partial<BaseCliMethodOptions>;
    }): Promise<void>;
    protected waitForProcessPortSavedToDisk(options: {
        methodOptions: BaseCliMethodOptions;
    }): Promise<void>;
    protected getServicePort(): Promise<number>;
}
