From 95aca5e1287d7ee9cf68819e8d63f8ea48a89512 Mon Sep 17 00:00:00 2001 From: echarles Date: Mon, 18 Dec 2023 17:26:56 +0100 Subject: [PATCH] chore: kill script --- dev/sh/kill.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dev/sh/kill.sh b/dev/sh/kill.sh index 957b8a3..882168f 100755 --- a/dev/sh/kill.sh +++ b/dev/sh/kill.sh @@ -3,8 +3,22 @@ # Copyright (c) Datalayer, Inc. https://datalayer.io # Distributed under the terms of the MIT License. +uname_out="$(uname -s)" + +case "${uname_out}" in + Linux*) export OS=LINUX;; + Darwin*) export OS=MACOS;; +# CYGWIN*) OS=CYGWIND;; +# MINGW*) OS=MINGW;; + *) export OS="UNSUPPORTED:${unameOut}" +esac + function kill_port() { - lsof -i TCP:$1 | grep LISTEN | awk '{print $2}' | xargs kill -9 + case "${OS}" in + LINUX) fuser -k $1/tcp;; + MACOS) lsof -i TCP:$1 | grep LISTEN | awk '{print $2}' | xargs kill -9;; + *) echo "Unsupported operating system ${OS}" + esac } kill_port 3063