UNPKG

iobroker.js-controller

Version:

Updated by reinstall.js on 2018-06-11T15:19:56.688Z

161 lines 5.37 kB
import http from 'node:http'; import https from 'node:https'; import type { Client as ObjectsClient } from '@iobroker/db-objects-redis'; import type { Client as StatesClient } from '@iobroker/db-states-redis'; import type { Logger } from 'winston'; interface Certificates { /** Public certificate */ certPublic: string; /** Private certificate */ certPrivate: string; } interface InsecureWebServerParameters { /** if https should be used for the webserver */ useHttps: false; /** port of the web server */ port: number; } type SecureWebServerParameters = Omit<InsecureWebServerParameters, 'useHttps'> & { useHttps: true; certPrivateName: string; certPublicName: string; }; type WebServerParameters = InsecureWebServerParameters | SecureWebServerParameters; export type AdapterUpgradeManagerOptions = { /** Version of adapter to upgrade too */ version: string; /** Name of the adapter to upgrade */ adapterName: string; /** The objects DB client */ objects: ObjectsClient; /** The states DB client */ states: StatesClient; /** A logger instance */ logger: Logger; } & WebServerParameters; interface GetCertificatesParams { /** Name of the public certificate */ certPublicName: string; /** Name of the private certificate */ certPrivateName: string; } export declare class AdapterUpgradeManager { /** Wait ms until adapter is stopped */ private readonly STOP_TIMEOUT_MS; /** Wait ms for delivery of final response */ private readonly SHUTDOWN_TIMEOUT; /** Name of the adapter to upgrade */ private readonly adapterName; /** Desired adapter version */ private readonly version; /** Response send by webserver */ private readonly response; /** Used to stop the stop shutdown timeout */ private shutdownAbortController?; /** Logger to log to file and other transports */ private readonly logger; /** The server used for communicating upgrade status */ private server?; /** All socket connections of the webserver */ private sockets; /** Name of the host for logging purposes */ private readonly hostname; /** The objects DB client */ private readonly objects; /** The states DB client */ private readonly states; /** List of instances which have been stopped */ private stoppedInstances; /** If webserver should be started with https */ private readonly useHttps; /** Public certificate name if https is desired */ private readonly certPublicName?; /** Private certificate name if https is desired */ private readonly certPrivateName?; /** Port where the webserver should be running */ private readonly port; constructor(options: AdapterUpgradeManagerOptions); /** * Stops the adapter and returns ids of stopped instances */ stopAdapter(): Promise<void>; /** * Start all instances which were enabled before the upgrade */ startAdapter(): Promise<void>; /** * Start or stop given instances * * @param instances id of instances which will be stopped * @param enabled if enable or disable instances */ enableInstances(instances: string[], enabled: boolean): Promise<void>; /** * Install given version of adapter */ performUpgrade(): Promise<void>; /** * Starts the web server for admin communication either secure or insecure */ startWebServer(): Promise<void>; /** * Shuts down the server, restarts the adapter */ shutdownServer(): void; /** * Destroy all sockets, to prevent requests from keeping server alive */ destroySockets(): void; /** * This function is called when the webserver receives a message * * @param req received message * @param res server response */ webServerCallback(req: http.IncomingMessage, res: http.ServerResponse): void; /** * Get all instances of the adapter */ getAllEnabledInstances(): Promise<string[]>; /** * Log via logger and provide the logs for the server too * * @param message the message which will be logged * @param error if it is an error */ log(message: string, error?: boolean): void; /** * Start an insecure web server for admin communication * * @param params Web server configuration */ startInsecureWebServer(params: InsecureWebServerParameters): void; /** * Start a secure web server for admin communication * * @param params Web server configuration */ startSecureWebServer(params: SecureWebServerParameters): Promise<void>; /** * Keep track of all existing sockets * * @param server the webserver */ monitorSockets(server: http.Server | https.Server): void; /** * Get certificates from the DB * * @param params certificate information */ getCertificates(params: GetCertificatesParams): Promise<Certificates>; /** * Tells the upgrade manager, that server can be shut down on next response or on timeout */ private setFinished; /** * Start a timeout which starts adapter and shuts down the server if expired */ startShutdownTimeout(): Promise<void>; } export {}; //# sourceMappingURL=adapterUpgradeManager.d.ts.map