You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

19 lines
681 B

#!/bin/bash
PORT=3000
pid_rails=$(ss -tlnp | grep "$PORT" | grep -oP "pid=\K(\d+)" | head -n1)
if [[ -n $pid_rails ]]; then
echo "============================================================================"
echo "Rails already runs on port $PORT, You've asked for debugger on the same port."
echo "============================================================================"
echo -n "Do you to want to kill rails process in order to launch debugger: (y/N)?: "
read -n1 answer
case $(echo $answer | tr '[A-Z]' '[a-z]') in
y|yes) kill -15 $pid_rails ;;
*) echo " means NO"; exit 1 ;;
esac
else
echo "port $PORT is free for debugger, go on..."
fi