mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-11 03:27:47 +08:00
New typings for recluster
This commit is contained in:
46
types/recluster/index.d.ts
vendored
Normal file
46
types/recluster/index.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// Type definitions for recluster 0.4
|
||||
// Project: https://github.com/doxout/recluster
|
||||
// Definitions by: Piotr Roszatycki <https://github.com/dex4er>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { ChildProcess } from "child_process";
|
||||
|
||||
export interface LogOptions {
|
||||
respawns?: boolean;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
log(message?: any, ...optionalParams: any[]): void;
|
||||
}
|
||||
|
||||
export interface BalancerOptions {
|
||||
/** number of active workers */
|
||||
workers?: number;
|
||||
/** kill timeout for old workers after reload (sec) */
|
||||
timeout?: number;
|
||||
/** min time between respawns when workers die */
|
||||
respawn?: number;
|
||||
/** max time between respawns when workers die */
|
||||
backoff?: number;
|
||||
/** when does the worker become ready? 'listening' or 'started' */
|
||||
readyWhen?: string;
|
||||
/** arguments to pass to the worker (default: []) */
|
||||
args?: string[];
|
||||
/** what to log to stdout (default: {respawns: true}) */
|
||||
log?: LogOptions;
|
||||
/** logger to use, needs `log` method (default: console) */
|
||||
logger?: Logger;
|
||||
}
|
||||
|
||||
export class Balancer {
|
||||
constructor(file: string, options: BalancerOptions);
|
||||
run(): void;
|
||||
reload(cb?: () => void): void;
|
||||
stop(): void;
|
||||
workers(): ChildProcess[];
|
||||
activeWorkers(): ChildProcess[];
|
||||
}
|
||||
|
||||
export default function recluster(file: string, options?: BalancerOptions): Balancer;
|
||||
9
types/recluster/recluster-tests.ts
Normal file
9
types/recluster/recluster-tests.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import recluster from "recluster";
|
||||
import path = require("path");
|
||||
|
||||
const cluster = recluster(path.join(__dirname, 'server.js'));
|
||||
cluster.run();
|
||||
|
||||
process.on('SIGUSR2', () => {
|
||||
cluster.reload();
|
||||
});
|
||||
24
types/recluster/tsconfig.json
Normal file
24
types/recluster/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"recluster-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/recluster/tslint.json
Normal file
1
types/recluster/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user