taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 0dbb4ddd2b8073ac716e7a57a5280a8278d0d56a
parent cd0d58753254f445a1ad80aa883025bc2bc63de2
Author: Florian Dold <florian@dold.me>
Date:   Mon, 22 Apr 2024 19:56:05 +0200

taler-wallet-cli: clean up socket

Diffstat:
Mpackages/taler-wallet-cli/src/index.ts | 21++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts @@ -1210,7 +1210,26 @@ advancedCli help: "Do not initialize the wallet. The client must send the initWallet message.", }) .action(async (args) => { - logger.info(`serving at ${args.serve.unixPath}`); + const socketPath = args.serve.unixPath; + logger.info(`serving at ${socketPath}`); + let cleanupCalled = false; + + const cleanupSocket = (signal: string, code: number) => { + if (cleanupCalled) { + return; + } + cleanupCalled = true; + try { + logger.info("cleaning up socket"); + fs.unlinkSync(socketPath); + } catch (e) { + logger.warn(`unable to clean up socket: ${e}`); + } + process.exit(128 + code); + }; + process.on("SIGTERM", cleanupSocket); + process.on("SIGINT", cleanupSocket); + const onNotif = (notif: WalletNotification) => { if (observabilityEventFile) { switch (notif.type) {