From 24b2c9d64eb8866199843132b02e6780674f2538 Mon Sep 17 00:00:00 2001 From: Dean Lofts Date: Sat, 24 Aug 2024 18:12:42 +1000 Subject: [PATCH] add script to stop processes --- stop_processes.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 stop_processes.sh diff --git a/stop_processes.sh b/stop_processes.sh new file mode 100755 index 0000000..cb80519 --- /dev/null +++ b/stop_processes.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Function to stop a process by its name or port +stop_process() { + local NAME=$1 + local PID_COMMAND=$2 + local PID=$($PID_COMMAND) + + if [ -n "$PID" ]; then + kill -9 $PID + echo "Stopped $NAME process." + else + echo "No $NAME process running." + fi +} + +# Stop Rails server running on port 3000 +PORT=3000 +stop_process "Rails server on port $PORT" "lsof -i tcp:$PORT -t" + +# Stop any running Sidekiq processes +stop_process "Sidekiq" "pgrep -f sidekiq" + +# Stop any running Vite processes +stop_process "Vite" "pgrep -f vite" + +echo "All specified processes have been checked and stopped if running."