Last active
January 27, 2018 14:47
-
-
Save jkutner/2912686d514c37189cb49b71c6e7333a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#! /bin/bash | |
BOOT_TIMEOUT=55 | |
forward_wrong_port() { | |
sleep $BOOT_TIMEOUT | |
local ports="$(ss -lt | awk '/LISTEN/ { print $4 }' | grep "*:[0-9]*")" | |
if echo "$ports" | grep -v "*:$PORT$"; then | |
local user_port="$(echo "$ports" | sed 's/\*://' | head -n 1)" | |
socat TCP-LISTEN:$PORT,fork TCP:0.0.0.0:$user_port | |
fi | |
} | |
forward_wrong_port & | |
This file contains hidden or 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
#! /bin/bash | |
BOOT_TIMEOUT=60 | |
warn_wrong_port() { | |
local end=$((SECONDS+BOOT_TIMEOUT)) | |
while [ $SECONDS -lt $end ]; do | |
local ports="$(ss -lt | awk '/LISTEN/ { print $4 }' | grep "*:[0-9]*" | sed 's/\*://')" | |
for port in $ports; do | |
if [ "$port" != "$PORT" ]; then | |
echo "WARNING: Your app is binding to $port instead of the value defined by the \$PORT environment variable. You may recevie an R10 error." | |
fi | |
done | |
sleep 10 | |
done | |
} | |
warn_wrong_port & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment