Last active
July 29, 2018 13:54
-
-
Save JamesKyburz/b1a79295a13e133cfefdb9ebe4265b7b to your computer and use it in GitHub Desktop.
debug server-base-docker processes with node --inspect-brk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
service=$1 | |
if [ "`uname`" == "Darwin" ] && ! [ -x "$(command -v chrome-cli)" ]; then | |
brew install chrome-cli | |
fi | |
docker-compose kill $service | |
docker-compose rm -f $service | |
cat << EOF > docker-compose.debug.yml | |
version: '3' | |
services: | |
$service: | |
command: sh -c "yarn prestart ; node --inspect-brk=0.0.0.0:9229 /usr/src/app/src/index" | |
ports: | |
- "9229:9229" | |
EOF | |
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.debug.yml up -d --build $service | |
while true | |
do | |
url=$(docker-compose logs --tail 100 $service | grep chrome | tail -n 1 | awk '{print $3}') | |
if [ "$url" != "" ]; then | |
break | |
fi | |
done | |
if [ "`uname`" == "Darwin" ]; then | |
echo $url | xargs -0 chrome-cli open | |
else | |
echo "open $url in chrome" | |
fi | |
echo "press any key to stop debugging" | |
read -n 1 | |
rm -rf docker-compose.debug.yml | |
echo "" | |
echo "restarting $service without debug" | |
docker-compose kill $service | |
docker-compose rm -f $service | |
docker-compose up -d --build $service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment