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

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