diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a725465 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +vendor/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c19abf0 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +### openethereum-node-status + +A tiny stateless service to return health status and useful metrics from OpenEthereum/Parity nodes. Requires the [following API's](https://openethereum.github.io/JSONRPC) to be enabled: + +- eth +- parity + +#### Endpoints + +- `/health` (Expect 200 for health with an additional JSON object with more info) +- `/metrics` (Expect 200 for health with an additional JSON object with more info) + +#### Development + +`DEBUG_ENABLED=true go run cmd/node-status/main.go` diff --git a/internal/server/router.go b/internal/server/router.go index e547b49..2e1ca75 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -24,15 +24,14 @@ func healthHandler(c *gin.Context) { fmt.Println(data.SyncComplete) if !allOk { + // choose a better status code if available c.JSON(http.StatusExpectationFailed, gin.H{ - "ok": false, "message": "could not get node health status", }) return } c.JSON(http.StatusOK, gin.H{ - "ok": true, "syncComplete": data.SyncComplete, "chainName": data.ChainName, })