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
|
||||
include_role: name=consul-service
|
||||
vars:
|
||||
|
@ -43,8 +27,8 @@
|
|||
stage: '{{ stage }}'
|
||||
checks:
|
||||
- id: '{{ geth_cont_name }}-rpc-status'
|
||||
type: script
|
||||
script: '{{ geth_sync_check_script }}'
|
||||
type: 'script'
|
||||
script: '{{ geth_service_path }}/rpc.sh eth_syncing'
|
||||
timeout: '5s'
|
||||
|
||||
- name: '{{ geth_cont_name }}-ws'
|
||||
|
|
|
@ -1,30 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
# vim: set ft=sh:
|
||||
set -euo pipefail
|
||||
|
||||
URL="http://localhost:{{ geth_rpc_port }}/"
|
||||
|
||||
METHOD="$1"
|
||||
shift
|
||||
PARAMS=("$@")
|
||||
|
||||
if [[ -z "${METHOD}" ]]; then
|
||||
echo "No method specified!" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ -n "${PARAMS}" ]]; then
|
||||
PARAMS_STR=$(printf '%s\",\"' "${PARAMS[@]}")
|
||||
PARAMS_STR="\"${PARAMS_STR%%\",\"}\""
|
||||
if [[ -n "${@}" ]]; then
|
||||
PARAMS=$(printf '%s\",\"' "${@}")
|
||||
PARAMS="\"${PARAMS_STR%%\",\"}\""
|
||||
else
|
||||
PARAMS_STR=''
|
||||
PARAMS=''
|
||||
fi
|
||||
|
||||
PAYLOAD="{
|
||||
\"id\": 1,
|
||||
\"jsonrpc\": \"2.0\",
|
||||
\"method\": \"${METHOD}\",
|
||||
\"params\": [${PARAMS_STR}]
|
||||
\"params\": [${PARAMS}]
|
||||
}"
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Content-type:application/json" \
|
||||
--data "${PAYLOAD}" \
|
||||
"${URL}" | jq .
|
||||
"${URL}" | \
|
||||
jq -e '., if .error != null then null|halt_error(2) else halt end'
|
||||
|
|
Loading…
Reference in New Issue