This repository was archived by the owner on Feb 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +59
-13
lines changed
Expand file tree Collapse file tree 5 files changed +59
-13
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,4 @@ before_script:
2020
2121script :
2222 - ./hooks/build
23- - ./hooks/test
23+ - ./hooks/travis_test
Original file line number Diff line number Diff line change @@ -27,4 +27,7 @@ VOLUME /app
2727
2828EXPOSE 6001
2929
30+ HEALTHCHECK --interval=30s --timeout=5s \
31+ CMD /usr/local/bin/health-check
32+
3033CMD ["start" ]
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -x
3+
4+ _init () {
5+ scheme=" http://"
6+ address=" $( netstat -nplt 2> /dev/null | awk ' /(.*\/laravel-echo-serv)/ { gsub(":::","127.0.0.1:",$4); print $4}' ) "
7+ resource=" /socket.io/socket.io.js"
8+ start=$( stat -c " %Y" /proc/1)
9+ }
10+
11+ fn_health_check () {
12+ # In distributed environment like Swarm, traffic is routed
13+ # to a container only when it reports a `healthy` status. So, we exit
14+ # with 0 to ensure healthy status till distributed service starts (120s).
15+ #
16+ # Refer: https://github.com/moby/moby/pull/28938#issuecomment-301753272
17+ if [[ $(( $(date +% s) - start )) -lt 120 ]]; then
18+ exit 0
19+ else
20+ # Get the http response code
21+ http_response=$( curl -s -k -o /dev/null -w " %{http_code}" ${scheme}${address}${resource} )
22+
23+ # Get the http response body
24+ http_response_body=$( curl -k -s ${scheme}${address}${resource} )
25+
26+ # server returns response 403 and body "SSL required" if non-TLS
27+ # connection is attempted on a TLS-configured server. Change
28+ # the scheme and try again
29+ if [[ " $http_response " = " 403" ]] && \
30+ [[ " $http_response_body " = " SSL required" ]]; then
31+ scheme=" https://"
32+ http_response=$( curl -s -k -o /dev/null -w " %{http_code}" ${scheme}${address}${resource} )
33+ fi
34+
35+ # If http_response is 200 - server is up.
36+ [[ " $http_response " = " 200" ]]
37+ fi
38+ }
39+
40+ _init && fn_health_check
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ IMAGE_NAME=" oanhnn/laravel-echo-server:latest"
4+ LARAVEL_ECHO_SERVER_DB=" redis"
5+
6+ echo " => Testing the image ${IMAGE_NAME} "
7+ docker run -d --net=" host" \
8+ -e REDIS_HOST=localhost \
9+ -e LARAVEL_ECHO_SERVER_DB=${LARAVEL_ECHO_SERVER_DB} \
10+ ${IMAGE_NAME}
11+
12+ sleep 60
13+ docker ps
14+
15+ curl --retry 10 --retry-delay 2 -I http://127.0.0.1:6001/socket.io/socket.io.js
You can’t perform that action at this time.
0 commit comments