mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
rpc npm: rename shutdown method to close and add muteStdErr option to mute the stderr output (#5588)
This commit is contained in:
7
deltachat-rpc-server/npm-package/index.d.ts
vendored
7
deltachat-rpc-server/npm-package/index.d.ts
vendored
@@ -20,17 +20,20 @@ export function getRPCServerPath(
|
|||||||
|
|
||||||
|
|
||||||
export type DeltaChatOverJsonRpcServer = StdioDeltaChat & {
|
export type DeltaChatOverJsonRpcServer = StdioDeltaChat & {
|
||||||
shutdown: () => Promise<void>;
|
|
||||||
readonly pathToServerBinary: string;
|
readonly pathToServerBinary: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface StartOptions {
|
||||||
|
/** whether to disable outputting stderr to the parent process's stderr */
|
||||||
|
muteStdErr: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param directory directory for accounts folder
|
* @param directory directory for accounts folder
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
export function startDeltaChat(directory: string, options?: Partial<SearchOptions> ): Promise<DeltaChatOverJsonRpcServer>
|
export function startDeltaChat(directory: string, options?: Partial<SearchOptions & StartOptions> ): Promise<DeltaChatOverJsonRpcServer>
|
||||||
|
|
||||||
|
|
||||||
export namespace FnTypes {
|
export namespace FnTypes {
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ export async function startDeltaChat(directory, options) {
|
|||||||
RUST_LOG: process.env.RUST_LOG || "info",
|
RUST_LOG: process.env.RUST_LOG || "info",
|
||||||
DC_ACCOUNTS_PATH: directory,
|
DC_ACCOUNTS_PATH: directory,
|
||||||
},
|
},
|
||||||
|
stdio: ["pipe", "pipe", options.muteStdErr ? "ignore" : "inherit"],
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("error", (err) => {
|
server.on("error", (err) => {
|
||||||
@@ -144,13 +145,11 @@ export async function startDeltaChat(directory, options) {
|
|||||||
throw new Error("Server quit");
|
throw new Error("Server quit");
|
||||||
});
|
});
|
||||||
|
|
||||||
server.stderr.pipe(process.stderr);
|
|
||||||
|
|
||||||
/** @type {import('./index').DeltaChatOverJsonRpcServer} */
|
/** @type {import('./index').DeltaChatOverJsonRpcServer} */
|
||||||
//@ts-expect-error
|
//@ts-expect-error
|
||||||
const dc = new StdioDeltaChat(server.stdin, server.stdout, true);
|
const dc = new StdioDeltaChat(server.stdin, server.stdout, true);
|
||||||
|
|
||||||
dc.shutdown = async () => {
|
dc.close = () => {
|
||||||
shouldClose = true;
|
shouldClose = true;
|
||||||
if (!server.kill()) {
|
if (!server.kill()) {
|
||||||
console.log("server termination failed");
|
console.log("server termination failed");
|
||||||
|
|||||||
Reference in New Issue
Block a user