REST API: add a method to get the status of the services

added a status page to the built-in web admin
This commit is contained in:
Nicola Murino
2020-12-08 11:18:34 +01:00
parent 6977a4a18b
commit 50982229e1
22 changed files with 424 additions and 71 deletions

View File

@@ -9,7 +9,6 @@ import (
"github.com/go-chi/render"
"github.com/drakkan/sftpgo/common"
"github.com/drakkan/sftpgo/dataprovider"
"github.com/drakkan/sftpgo/logger"
"github.com/drakkan/sftpgo/metrics"
"github.com/drakkan/sftpgo/version"
@@ -66,13 +65,8 @@ func initializeRouter(staticFilesPath string, enableProfiler, enableWebAdmin boo
render.JSON(w, r, version.Get())
})
router.Get(providerStatusPath, func(w http.ResponseWriter, r *http.Request) {
err := dataprovider.GetProviderStatus()
if err != nil {
sendAPIResponse(w, r, err, "", http.StatusInternalServerError)
} else {
sendAPIResponse(w, r, err, "Alive", http.StatusOK)
}
router.Get(serverStatusPath, func(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, getServicesStatus())
})
router.Get(activeConnectionsPath, func(w http.ResponseWriter, r *http.Request) {
@@ -106,6 +100,7 @@ func initializeRouter(staticFilesPath string, enableProfiler, enableWebAdmin boo
router.Get(webFoldersPath, handleWebGetFolders)
router.Get(webFolderPath, handleWebAddFolderGet)
router.Post(webFolderPath, handleWebAddFolderPost)
router.Get(webStatusPath, handleWebGetStatus)
}
})