Shows a list of all node processes and lets you select which one you want to debug.
For example
$ debug.sh
1) 73428 node webpack/webpackDevServer.js
2) 73494 node build/dist/server.js
Select which process to debug: █
#!/usr/bin/env bash | |
# Get info for all node processes | |
PROCESSES=$(ps | grep ' node ') | |
# Split on lines instead of spaces | |
IFS=$'\n' | |
# Change select prompt | |
PS3='Select which process to debug: ' | |
# Prompt user for node process to signal | |
select PROCESS in $PROCESSES | |
do | |
# Split on spaces | |
IFS=' ' | |
# Get array of parts, first part is PID | |
PARTS=( $PROCESS ) | |
# Send signal to node process to start debugger | |
kill -SIGUSR1 $PARTS | |
break | |
done |