summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-04-22 19:56:05 +0200
committerFlorian Dold <florian@dold.me>2024-04-22 19:56:05 +0200
commit0dbb4ddd2b8073ac716e7a57a5280a8278d0d56a (patch)
treef177f28cf812620800806a48f05d21956ae3279f /packages
parentcd0d58753254f445a1ad80aa883025bc2bc63de2 (diff)
downloadwallet-core-0dbb4ddd2b8073ac716e7a57a5280a8278d0d56a.tar.gz
wallet-core-0dbb4ddd2b8073ac716e7a57a5280a8278d0d56a.tar.bz2
wallet-core-0dbb4ddd2b8073ac716e7a57a5280a8278d0d56a.zip
taler-wallet-cli: clean up socket
Diffstat (limited to 'packages')
-rw-r--r--packages/taler-wallet-cli/src/index.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts
index 1cceb8446..59be964b2 100644
--- 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) {