rawx
Version:
process daemon with utilities
129 lines (128 loc) • 3.66 kB
TypeScript
export declare namespace P {
interface Pre_Init_Procs_Arg {
procs?: Proc_Args;
proc?: Proc_Args;
}
type Type = P_Type | H.Hook_Type;
type P_Type = "exec" | "spawn" | "execFile" | "fork";
interface Core {
type: Type;
chain_exit?: "success" | true;
chain_next?: number;
chain_failure?: number;
on_watch?: true;
run_if_file_dne?: str;
goto_on_file_exists?: number;
concurrent?: P.A_Proc_Arg;
delay?: number;
trap?: true;
silence?: P.Silencer;
}
interface Proc_Arg_Exec extends Core {
type: "exec";
command: str;
}
interface Proc_Arg_Def extends Core {
type: "spawn" | "execFile";
command: str;
args?: Array<str>;
cwd?: str;
shell?: true;
}
interface Proc_Arg_Fork extends Core {
type: "fork";
module: "str";
}
type Silencer = "some" | "all";
type A_Proc_Arg = Proc_Arg_Def | Proc_Arg_Exec | Proc_Arg_Fork | H.Hook;
type Proc_Args = Array<A_Proc_Arg> | A_Proc_Arg;
type P_Args = readonly str[];
type Repeater_Args_Arr = Array<P_Args>;
type str = string;
}
export declare namespace H {
type Hook_Type = "fn" | "exec_fn";
interface Hook extends P.Core {
type: Proc_Hook_Type;
fn: Fn_W_Callback | Exec_Hook_Args;
}
type Proc_Hook_Type = "fn" | "exec_fn";
type Fn_Callback_W_Code = (code: number) => void;
type Fn_W_Callback_Args = {
callback: Fn_Callback_W_Code;
file_path?: str;
fail?: Rej;
};
type Fn_W_Callback = (args: Fn_W_Callback_Args) => void;
type Get_Exec_Hook_Args = {
callback: Post_Hook_Exec;
file_path?: str;
fail?: Rej;
};
type Exec_Hook_Args = (args: Get_Exec_Hook_Args) => str;
type Post_Hook_Exec = (args: Exec_Light) => void;
interface Exec_Light {
command: str;
}
type Rej = (err: Error) => void;
interface _Hook_Fn extends _P._Proc {
fn: H.Fn_W_Callback | H.Exec_Hook_Args;
}
interface _Hook_Exec_Args {
proc: _Hook_Fn;
trigger_file_path?: str;
}
}
export declare namespace _P {
interface _Proc extends P.Core {
_conc: _Proc;
_proc_id: str;
_sidecar: _Sidecar;
}
interface _Sidecar {
label: str;
silence?: P.Silencer;
delay?: number;
}
type _Proc_W_Conf = _Proc_Def | _Proc_Exec | _Proc_Fork;
interface _Proc_Def extends _Proc {
type: "spawn" | "execFile";
construct: _Run_Proc_Conf;
}
interface _Proc_Exec extends _Proc {
type: "exec";
command: str;
construct: _Run_Exec_Conf;
}
interface _Proc_Fork extends _Proc {
type: "fork";
construct: _Run_Fork_Conf;
}
interface _Run_Proc_Conf {
type: "spawn" | "execFile";
command: str;
args: readonly str[] | P.Repeater_Args_Arr;
repeater_chain?: true | "success";
options?: {
cwd?: str;
shell?: true;
};
}
interface _Run_Exec_Conf {
type: "exec";
command: str;
cwd?: str;
}
interface _Run_Fork_Conf {
type: "fork";
module: str;
args: readonly str[];
options: {
cwd: str;
execPath?: str | undefined;
execArgv?: str[] | undefined;
detached?: boolean | undefined;
};
}
}
export declare type str = string;