Skip to content

Commit

Permalink
add script to stop processes
Browse files Browse the repository at this point in the history
  • Loading branch information
loftwah committed Aug 24, 2024
1 parent cc74d5e commit 24b2c9d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions stop_processes.sh
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 24b2c9d

Please sign in to comment.