-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.d.ts
46 lines (46 loc) · 1.63 KB
/
lib.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/// <reference types="node" />
import EventEmitter = require('events');
import { ExecOptions, SpawnOptions, ChildProcess } from 'child_process';
interface DaemonOptions {
command?: string;
args?: string[];
options?: SpawnOptions | ExecOptions;
maxRestartTimes?: number;
restartDelay?: number;
exec?: boolean;
}
interface Daemon {
emit(event: 'start', childProcess: ChildProcess): boolean;
on(event: 'start', listener: (childProcess: ChildProcess) => void): this;
emit(event: 'restart', childProcess: ChildProcess): boolean;
on(event: 'restart', listener: (childProcess: ChildProcess) => void): this;
emit(event: 'error', err: Error): boolean;
on(event: 'error', listener: (err: Error) => void): this;
emit(event: 'stop', childProcess: ChildProcess): boolean;
on(event: 'stop', listener: (childProcess: ChildProcess) => void): this;
emit(event: 'exit', code: number, signal: string): boolean;
on(event: 'exit', listener: (code: number, signal: string) => void): this;
}
declare class Daemon extends EventEmitter implements DaemonOptions {
constructor(options?: DaemonOptions);
command: string;
args: string[];
options: SpawnOptions | ExecOptions;
maxRestartTimes: number;
restartDelay: number;
exec: boolean;
private _restartTimes;
readonly restartTimes: number;
private _childProcess?;
readonly childProcess: ChildProcess | undefined;
private _active;
readonly active: boolean;
private _start;
private _restartTimer?;
private _restart;
private _stop;
start(): this;
reset(): this;
stop(signal?: string): this;
}
export = Daemon;