- Learning Spring Boot 2.0(Second Edition)
- Greg L. Turnquist
- 200字
- 2021-07-02 15:18:07
Pinging our app for general health
Each of these endpoints can be visited using our browser or using other tools like curl:
$ curl localhost:9000/application/health {
"status": "UP",
"details": {
"mongo": {
"status": "UP",
"details": {
"version": "3.2.2"
}
},
"diskSpace": {
"status": "UP",
"details": {
"total": 498937626624,
"free": 66036432896,
"threshold": 10485760
}
}
}
}
This preceding health status gives us the following:
- An overall UP status
- The status of MongoDB
- The status of the diskspace
When other components are added, they may, optionally, add their own health checks.
This immediately solves our first need listed previously. We can inform the system administrator that he or she can write a management script to interrogate our app's health.
Be warned that each of these endpoints serve up a compact JSON document. Generally speaking, command-line curl probably isn't the best option. While it's convenient on *nix and Mac systems, the content is dense and hard to read. It's more practical to have the following:
- a JSON plugin installed in our browser (such as JSON Viewer at https://github.com/tulios/json-viewer)
- a script that uses a JSON parsing library if we're writing a management script (such as Groovy's JsonSlurper at http://docs.groovy-lang.org/latest/html/gapi/groovy/json/JsonSlurper.html or JsonPath at https://code.google.com/p/json-path)
推薦閱讀
- Git Version Control Cookbook
- INSTANT FreeMarker Starter
- HDInsight Essentials(Second Edition)
- Java程序設(shè)計:原理與范例
- Getting Started with NativeScript
- Mastering Apache Maven 3
- Python深度學(xué)習(xí):模型、方法與實現(xiàn)
- Hands-On GUI Programming with C++ and Qt5
- Go語言從入門到精通
- Mastering VMware Horizon 7(Second Edition)
- 深入分析GCC
- Android高級開發(fā)實戰(zhàn):UI、NDK與安全
- 原型設(shè)計:打造成功產(chǎn)品的實用方法及實踐
- XML程序設(shè)計(第二版)
- Android應(yīng)用程序設(shè)計