Skip to content

Instantly share code, notes, and snippets.

@tamlyn tamlyn/README.md
Last active Mar 14, 2018

Embed
What would you like to do?
Start debugging a running node process

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.