mirror of
https://github.com/status-im/infra-role-geth.git
synced 2025-02-17 22:36:38 +00:00
use rpc.sh script for RPC healthcheck
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
1db9eb2f6c
commit
18382d60d1
@ -1,20 +1,4 @@
|
|||||||
---
|
---
|
||||||
- name: Geth | Create sync check script
|
|
||||||
copy:
|
|
||||||
dest: '{{ geth_sync_check_script }}'
|
|
||||||
mode: 0755
|
|
||||||
content: |
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -e
|
|
||||||
echo -n "Geth synced: "
|
|
||||||
RESP=$(curl -s -X POST \
|
|
||||||
--connect-timeout 5 \
|
|
||||||
-H 'Content-type:application/json' \
|
|
||||||
--data '{"jsonrpc":"2.0","method":"eth_syncing","id":1}' \
|
|
||||||
http://localhost:{{ geth_rpc_port }}/)
|
|
||||||
echo "${RESP}" | jq -e ".result == false" \
|
|
||||||
|| ( echo "${RESP}" | jq . ; exit 1 )
|
|
||||||
|
|
||||||
- name: Geth | Create Consul service definition
|
- name: Geth | Create Consul service definition
|
||||||
include_role: name=consul-service
|
include_role: name=consul-service
|
||||||
vars:
|
vars:
|
||||||
@ -43,8 +27,8 @@
|
|||||||
stage: '{{ stage }}'
|
stage: '{{ stage }}'
|
||||||
checks:
|
checks:
|
||||||
- id: '{{ geth_cont_name }}-rpc-status'
|
- id: '{{ geth_cont_name }}-rpc-status'
|
||||||
type: script
|
type: 'script'
|
||||||
script: '{{ geth_sync_check_script }}'
|
script: '{{ geth_service_path }}/rpc.sh eth_syncing'
|
||||||
timeout: '5s'
|
timeout: '5s'
|
||||||
|
|
||||||
- name: '{{ geth_cont_name }}-ws'
|
- name: '{{ geth_cont_name }}-ws'
|
||||||
|
@ -1,30 +1,32 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# vim: set ft=sh:
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
URL="http://localhost:{{ geth_rpc_port }}/"
|
URL="http://localhost:{{ geth_rpc_port }}/"
|
||||||
|
|
||||||
METHOD="$1"
|
METHOD="$1"
|
||||||
shift
|
shift
|
||||||
PARAMS=("$@")
|
|
||||||
|
|
||||||
if [[ -z "${METHOD}" ]]; then
|
if [[ -z "${METHOD}" ]]; then
|
||||||
echo "No method specified!" >&2
|
echo "No method specified!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ -n "${PARAMS}" ]]; then
|
if [[ -n "${@}" ]]; then
|
||||||
PARAMS_STR=$(printf '%s\",\"' "${PARAMS[@]}")
|
PARAMS=$(printf '%s\",\"' "${@}")
|
||||||
PARAMS_STR="\"${PARAMS_STR%%\",\"}\""
|
PARAMS="\"${PARAMS_STR%%\",\"}\""
|
||||||
else
|
else
|
||||||
PARAMS_STR=''
|
PARAMS=''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PAYLOAD="{
|
PAYLOAD="{
|
||||||
\"id\": 1,
|
\"id\": 1,
|
||||||
\"jsonrpc\": \"2.0\",
|
\"jsonrpc\": \"2.0\",
|
||||||
\"method\": \"${METHOD}\",
|
\"method\": \"${METHOD}\",
|
||||||
\"params\": [${PARAMS_STR}]
|
\"params\": [${PARAMS}]
|
||||||
}"
|
}"
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Content-type:application/json" \
|
-H "Content-type:application/json" \
|
||||||
--data "${PAYLOAD}" \
|
--data "${PAYLOAD}" \
|
||||||
"${URL}" | jq .
|
"${URL}" | \
|
||||||
|
jq -e '., if .error != null then null|halt_error(2) else halt end'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user