From 8e4bf59686346aa5b8dca29ee4a619cc7f07a686 Mon Sep 17 00:00:00 2001 From: Alessio Davoli Date: Wed, 19 Jul 2023 16:00:34 +0200 Subject: [PATCH] Add grateful exit on SIGINT AND SIGTERM --- frontend/add-sigint.sh | 8 ++++++++ frontend/package.json | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100755 frontend/add-sigint.sh diff --git a/frontend/add-sigint.sh b/frontend/add-sigint.sh new file mode 100755 index 0000000..0ba4eea --- /dev/null +++ b/frontend/add-sigint.sh @@ -0,0 +1,8 @@ +#!/usr/bin/bash + +echo "function shutdownGracefully() { + process.exit(0); +} + +process.on('SIGINT', shutdownGracefully); +process.on('SIGTERM', shutdownGracefully);" >> ./build/index.js diff --git a/frontend/package.json b/frontend/package.json index f0327bf..7c74348 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,7 +4,8 @@ "private": true, "scripts": { "dev": "vite dev", - "build": "vite build", + "build": "vite build && yarn add-sigint", + "add-sigint": "./add-sigint.sh", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",