@deepkit/framework
Version:
100 lines (99 loc) • 4.52 kB
TypeScript
import { RpcClient, RpcKernel } from '@deepkit/rpc';
import { HttpRouter } from '@deepkit/http';
import { BaseEvent, EventDispatcher, EventToken } from '@deepkit/event';
import { InjectorContext } from '@deepkit/injector';
import { FrameworkConfig } from './module.config.js';
import { LoggerInterface } from '@deepkit/logger';
import { WebWorker, WebWorkerFactory } from './worker.js';
import { RpcControllers } from './rpc.js';
import '@deepkit/type';
export declare class ServerBootstrapEvent extends BaseEvent {
}
/**
* Called only once for application server bootstrap (for main process and workers)
*/
export declare const onServerBootstrap: EventToken<ServerBootstrapEvent>;
/**
* Called only once for application server bootstrap (for main process and workers)
* as soon as the application server has started
*/
export declare const onServerBootstrapDone: EventToken<ServerBootstrapEvent>;
/**
* Called only once for application server bootstrap (in the main process)
* as soon as the application server starts.
*/
export declare const onServerMainBootstrap: EventToken<ServerBootstrapEvent>;
/**
* Called only once for application server bootstrap (in the main process)
* as soon as the application server has started.
*/
export declare const onServerMainBootstrapDone: EventToken<ServerBootstrapEvent>;
/**
* Called for each worker as soon as the worker bootstraps.
*/
export declare const onServerWorkerBootstrap: EventToken<ServerBootstrapEvent>;
/**
* Called only once for application server bootstrap (in the worker process)
* as soon as the application server has started.
*/
export declare const onServerWorkerBootstrapDone: EventToken<ServerBootstrapEvent>;
export declare class ServerShutdownEvent extends BaseEvent {
}
/**
* Called when application server shuts down (in master process and each worker).
*/
export declare const onServerShutdown: EventToken<ServerBootstrapEvent>;
/**
* Called when application server shuts down in the main process.
*/
export declare const onServerMainShutdown: EventToken<ServerBootstrapEvent>;
/**
* Called when application server shuts down in the worker process.
*/
export declare const onServerWorkerShutdown: EventToken<ServerBootstrapEvent>;
type ApplicationServerConfig = Pick<FrameworkConfig, 'server' | 'port' | 'host' | 'httpsPort' | 'ssl' | 'sslKey' | 'sslCertificate' | 'sslCa' | 'sslCrl' | 'varPath' | 'selfSigned' | 'workers' | 'publicDir' | 'debug' | 'debugUrl' | 'gracefulShutdownTimeout' | 'compression' | 'http' | 'logStartup'>;
export declare class LogStartupListener {
protected logger: LoggerInterface;
protected rpcControllers: RpcControllers;
protected router: HttpRouter;
protected config: ApplicationServerConfig;
protected server: ApplicationServer;
constructor(logger: LoggerInterface, rpcControllers: RpcControllers, router: HttpRouter, config: ApplicationServerConfig, server: ApplicationServer);
onBootstrapDone(): void;
}
export interface ApplicationServerOptions {
listenOnSignals?: boolean;
startHttpServer?: boolean;
}
export declare class ApplicationServer {
protected logger: LoggerInterface;
protected webWorkerFactory: WebWorkerFactory;
protected eventDispatcher: EventDispatcher;
protected rootScopedContext: InjectorContext;
config: ApplicationServerConfig;
protected rpcControllers: RpcControllers;
protected rpcKernel: RpcKernel;
protected router: HttpRouter;
protected httpWorker?: WebWorker;
protected started: boolean;
protected stopping: boolean;
protected onlineWorkers: number;
protected needsHttpWorker: boolean;
onStop: Promise<void>;
protected stopResolver: () => void;
constructor(logger: LoggerInterface, webWorkerFactory: WebWorkerFactory, eventDispatcher: EventDispatcher, rootScopedContext: InjectorContext, config: ApplicationServerConfig, rpcControllers: RpcControllers, rpcKernel: RpcKernel, router: HttpRouter);
getHttpWorker(): WebWorker;
/**
* Closes all server listener and triggers shutdown events. This is only used for integration tests.
*/
close(graceful?: boolean): Promise<void>;
protected stopWorkers(): Promise<void>;
start(optionsOrListenOnSignal?: boolean | ApplicationServerOptions): Promise<void>;
getHttpHost(): string | undefined;
getWorker(): WebWorker;
createClient(): RpcClient;
}
export declare class InMemoryApplicationServer extends ApplicationServer {
}
export {};
export declare type __ΩApplicationServerOptions = any[];