-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
BLOCKCHAIN_TIME=$(curl --silent --max-time 3 "http://localhost/status" |jq -r .result.sync_info.latest_block_time) | ||
|
||
if [[ ${BLOCKCHAIN_TIME} == "null" ]]; then | ||
echo Status: 502 | ||
echo Content-type:text/plain | ||
echo | ||
echo The node is currently not responding. | ||
exit 0 | ||
fi | ||
|
||
if [[ ! -z "$BLOCKCHAIN_TIME" ]]; then | ||
BLOCKCHAIN_SECS=`date -d $BLOCKCHAIN_TIME +%s` | ||
CURRENT_SECS=`date +%s` | ||
|
||
# if within 60 seconds of current time, call it synced and report healthy | ||
BLOCK_AGE=$((${CURRENT_SECS} - ${BLOCKCHAIN_SECS})) | ||
|
||
if [[ ${BLOCK_AGE} -le 60 ]]; then | ||
echo Status: 200 | ||
echo Content-type:text/plain | ||
echo | ||
echo latest_block_time is less than 60 seconds, this node is considered healthy. | ||
else | ||
echo Status: 503 | ||
echo Content-type:text/plain | ||
echo | ||
echo latest_block_time is higher than 60 seconds, this node is responding but not synced | ||
fi | ||
else | ||
echo Status: 502 | ||
echo Content-type:text/plain | ||
echo | ||
echo The node is currently not responding. | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
|
||
#user http; | ||
worker_processes 1; | ||
|
||
#error_log logs/error.log; | ||
#error_log logs/error.log notice; | ||
#error_log logs/error.log info; | ||
|
||
#pid logs/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include mime.types; | ||
default_type application/octet-stream; | ||
|
||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
# '$status $body_bytes_sent "$http_referer" ' | ||
# '"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
#access_log logs/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
#keepalive_timeout 0; | ||
keepalive_timeout 65; | ||
|
||
#gzip on; | ||
|
||
resolver 127.0.0.11 valid=30s; # Docker's DNS server | ||
|
||
server { | ||
listen 80; | ||
server_name localhost; | ||
#charset koi8-r; | ||
|
||
#access_log logs/host.access.log main; | ||
|
||
location / { | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-NginX-Proxy true; | ||
|
||
proxy_pass http://localhost:26657/; | ||
} | ||
|
||
location /healthcheck { | ||
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/healthcheck.sh; | ||
fastcgi_pass unix:/var/run/fcgiwrap.socket; | ||
} | ||
|
||
#error_page 404 /404.html; | ||
|
||
# redirect server error pages to the static page /50x.html | ||
# | ||
error_page 500 502 503 504 /50x.html; | ||
location = /50x.html { | ||
root /usr/share/nginx/html; | ||
} | ||
} | ||
} |
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