UNPKG

@eggjs/cluster

Version:

cluster manager for egg

83 lines (82 loc) 2.23 kB
import { SecureContextOptions } from "node:tls"; //#region src/utils/options.d.ts interface ClusterHTTPSSecureOptions { key: SecureContextOptions['key']; cert: SecureContextOptions['cert']; ca?: SecureContextOptions['ca']; passphrase?: SecureContextOptions['passphrase']; } type ClusterStartMode = 'process' | 'worker_threads'; /** Cluster start options */ interface ClusterOptions { /** * specify framework that can be absolute path or npm package */ framework?: string; /** * @deprecated please use framework instead */ customEgg?: string; /** directory of application, default to `process.cwd()` */ baseDir?: string; /** * numbers of app workers, default to `os.cpus().length` */ workers?: number | string; /** * listening port, default to `7001`(http) or `8443`(https) */ port?: number | string | null; /** * listening a debug port on http protocol */ debugPort?: number; /** * https options, { key, cert, ca }, full path */ https?: ClusterHTTPSSecureOptions | boolean; /** * @deprecated please use `options.https.key` instead */ key?: ClusterHTTPSSecureOptions['key']; /** * @deprecated please use `options.https.cert` instead */ cert?: ClusterHTTPSSecureOptions['cert']; /** * will inject into worker/agent process */ require?: string | string[]; /** * will save master pid to this file */ pidFile?: string; /** * custom env, default is `process.env.EGG_SERVER_ENV` */ env?: string; /** * default is `'process'`, use `'worker_threads'` to start the app & agent worker by worker_threads */ startMode?: ClusterStartMode; /** * startup port of each app worker, such as: `[7001, 7002, 7003]`, only effects when the startMode is `'worker_threads'` */ ports?: number[]; /** * sticky mode server */ sticky?: boolean; /** customized plugins, for unittest */ plugins?: object; isDebug?: boolean; } interface ParsedClusterOptions extends ClusterOptions { port?: number; baseDir: string; workers: number; framework: string; startMode: ClusterStartMode; } //#endregion export { ClusterHTTPSSecureOptions, ClusterOptions, ClusterStartMode, ParsedClusterOptions };