mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 05:36:07 +01:00
1 KiB
1 KiB
date | publishDate | tags | ||
---|---|---|---|---|
2024-10-29T10:35:52.127Z | 2024-10-29T10:35:52.127Z |
|
I just threw together a script for easily attaching a debugger to any of your overmind run processes. let me know if it's useful!
I'm using it for attaching to my rails processes, as I don't like how overmind connect web
echoes everything the web process outputs.
#!/usr/bin/env sh
if [[ "$1" == "--help" ]]; then
echo "Usage: $0 [web/worker/etc…]"
echo
echo "Attach an rdbg debugger to the named overmind process. (default: web)"
exit 0
fi
PROCESS=${1:-web}
PROCESS_PID=$(overmind ps | grep -E "^${PROCESS}" | tr -s ' ' | cut -d' ' -f2)
[[ -z $PROCESS_PID ]] && { echo "There is no running overmind process called '$PROCESS'" >&2; exit 1; }
DEBUGGER_PID=$(pgrep -P $PROCESS_PID)
[[ -z $DEBUGGER_PID ]] && { echo "The $PROCESS process doesn't seem to have any child processes" >&2; exit 1; }
bundle exec rdbg -An "rdbg-$DEBUGGER_PID"