chore: update Dockerfile and add health check for storage service
This commit is contained in:
parent
5b009b209f
commit
9b08ce09dc
3 changed files with 22 additions and 2 deletions
|
|
@ -90,7 +90,7 @@
|
|||
|
||||
</div>
|
||||
<div class="element">
|
||||
<a href="/health" class="button" style="background-color: green;">Health DB</a>
|
||||
<a href="/health" class="button" style="background-color: green;">Health Check</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -79,7 +79,15 @@ func (s *Server) SetupRoutes() *echo.Echo {
|
|||
})
|
||||
e.GET("/health", func(c echo.Context) error {
|
||||
h := queries.HealthCheck()
|
||||
return c.String(http.StatusOK, fmt.Sprintf("DB Connection: %v", h))
|
||||
|
||||
s_error := HealthCheckStorage()
|
||||
var s string
|
||||
if s_error != nil {
|
||||
s = s_error.Error()
|
||||
} else {
|
||||
s = "OK"
|
||||
}
|
||||
return c.JSONPretty(http.StatusOK, fmt.Sprintf("DB Connection: %v, Storage Connection: %v", h, s), " ")
|
||||
})
|
||||
|
||||
// MIOGEST ROUTES
|
||||
|
|
|
|||
|
|
@ -14,6 +14,18 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func HealthCheckStorage() error {
|
||||
resp, err := http.Get(config.Cfg.Storage.Endpoint + "/health")
|
||||
if err != nil {
|
||||
return fmt.Errorf("storage health check failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("storage health check failed: %s", resp.Status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeleteFile(id string) error {
|
||||
req, err := http.NewRequest("DELETE", config.Cfg.Storage.Endpoint+"/delete/"+id+"?token="+config.Cfg.Storage.Token, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue