Skip to content

Commit

Permalink
paranoid programming for checking socket
Browse files Browse the repository at this point in the history
  • Loading branch information
fgregg committed Nov 2, 2023
1 parent 1524733 commit 867738b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions scripts/app_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ supervisorctl add $APP_NAME-$DEPLOYMENT_ID

loop_counter=0
while true; do
SOCKET_EXISTS=`test -e "/tmp/$APP_NAME-$DEPLOYMENT_ID.sock" && echo 'yes' || echo 'no'`
# check to see if the socket file that the gunicorn process that is running
# the app has been created. If not, wait for a second.
if [[ $SOCKET_EXISTS == 'yes' ]]; then
if [[ -e "/tmp/$APP_NAME-${DEPLOYMENT_ID}.sock" ]]; then

# Pipe an HTTP request into the netcat tool (nc) and grep the response
# for the deployment ID. If it's not there, wait for a second.
running_app=`printf "GET /pong/ HTTP/1.1 \r\nHost: localhost \r\n\r\n" | nc -U /tmp/$APP_NAME-${DEPLOYMENT_ID}.sock | grep -e "$DEPLOYMENT_ID" || echo 'Bad deployment'`
running_app=`printf "GET /pong/ HTTP/1.1 \r\nHost: localhost \r\n\r\n" | nc -U /tmp/$APP_NAME-${DEPLOYMENT_ID}.sock | grep -e "$DEPLOYMENT_ID" -e 'Bad deployment*' || echo 'unknown error'`
echo $running_app
if [[ $running_app == $DEPLOYMENT_ID ]] ; then
echo "App matching $DEPLOYMENT_ID started"
Expand Down

0 comments on commit 867738b

Please sign in to comment.