diff --git a/Dockerfile b/Dockerfile index f5125c1..9c8d346 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,4 +30,7 @@ USER prism EXPOSE 8080 +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1 + CMD ["./prism"] diff --git a/README.md b/README.md index b1621d2..500377a 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ All notifications will now be sent to your Telegram chat. Unlike Signal, Telegra Receive notifications when new Proton Mail emails arrive. Unlike other integrations, this one will generate new messages to be delivered by one of the configured transports. Note that using this integration requires a paid Proton Mail account to be able to use the Proton Mail Bridge that this integration relies on. +Also note that the Proton Mail Bridge is RAM hungry. > **Note:** The default image (`shenxn/protonmail-bridge:build`) used by Prism compiles from source and supports all architectures. For x86_64 only, you can use `shenxn/protonmail-bridge:latest` (smaller, faster). @@ -246,8 +247,25 @@ curl -X DELETE http://localhost:8080/webpush/app/my-app \ The health of the system can be viewed in the same admin UI used for linking Signal. Prism uses [basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) - provide your `API_KEY` as the password (username can be anything). -For API-based monitoring, call `/api/health` which returns JSON: +### Health Endpoints + +#### GET /health + +Public health check endpoint (no authentication required). Returns `200 OK` when the service is running. Used for Docker health checks and load balancer health probes. + +```bash +curl http://localhost:8080/health +``` + +#### GET /api/health + +Detailed health endpoint (requires authentication). Returns JSON with uptime and integration status: + +```bash +curl http://localhost:8080/api/health \ + -H "Authorization: Bearer YOUR_API_KEY" +``` ```json -{"uptime":"3s","signal":{"linked":true},"proton":{"linked":true},"telegram":{"linked":true}} +{"version":"1.0.0","uptime":"3s","signal":{"linked":true},"proton":{"linked":true},"telegram":{"linked":true}} ``` diff --git a/service/server/handlers_health.go b/service/server/handlers_health.go index 188f185..60f05c4 100644 --- a/service/server/handlers_health.go +++ b/service/server/handlers_health.go @@ -9,6 +9,7 @@ import ( ) type healthResponse struct { + Version string `json:"version"` Uptime string `json:"uptime"` Signal *integrationHealth `json:"signal,omitempty"` Proton *integrationHealth `json:"proton,omitempty"` @@ -19,11 +20,16 @@ type integrationHealth struct { Linked bool `json:"linked"` } +func (s *Server) handleHealthCheck(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) +} + func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) { uptime := time.Since(s.startTime) resp := healthResponse{ - Uptime: util.FormatUptime(uptime), + Version: s.version, + Uptime: util.FormatUptime(uptime), } if s.integrations.Signal != nil && s.integrations.Signal.IsEnabled() { diff --git a/service/server/server.go b/service/server/server.go index 5994270..3d52b4a 100644 --- a/service/server/server.go +++ b/service/server/server.go @@ -123,6 +123,8 @@ func (s *Server) setupRoutes() { integration.RegisterAll(s.integrations, r, s.cfg, s.store, s.logger, authMiddleware) + r.Get("/health", s.handleHealthCheck) + r.With(authMiddleware(s.cfg.APIKey)).Get("/fragment/apps", s.handleFragmentApps) r.With(authMiddleware(s.cfg.APIKey)).Get("/fragment/integrations", s.handleFragmentIntegrations)