diff --git a/cmd/notifications/main.go b/cmd/notifications/main.go index 9dd947b74..46aa676bb 100644 --- a/cmd/notifications/main.go +++ b/cmd/notifications/main.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "net/http" "os" "os/signal" "syscall" @@ -28,7 +29,7 @@ import ( "github.com/polygonid/sh-id-platform/pkg/blockchain/eth" "github.com/polygonid/sh-id-platform/pkg/cache" "github.com/polygonid/sh-id-platform/pkg/credentials/revocation_status" - "github.com/polygonid/sh-id-platform/pkg/http" + httpPkg "github.com/polygonid/sh-id-platform/pkg/http" "github.com/polygonid/sh-id-platform/pkg/pubsub" "github.com/polygonid/sh-id-platform/pkg/reverse_hash" ) @@ -102,7 +103,7 @@ func main() { return } - notificationGateway := gateways.NewPushNotificationClient(http.DefaultHTTPClientWithRetry) + notificationGateway := gateways.NewPushNotificationClient(httpPkg.DefaultHTTPClientWithRetry) notificationService := services.NewNotification(notificationGateway, connectionsService, credentialsService) ctxCancel, cancel := context.WithCancel(ctx) defer func() { @@ -120,6 +121,20 @@ func main() { gracefulShutdown := make(chan os.Signal, 1) signal.Notify(gracefulShutdown, syscall.SIGINT, syscall.SIGTERM) + go func() { + http.Handle("/status", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, err := w.Write([]byte("OK")) + if err != nil { + log.Error(ctx, "error writing response", "err", err) + } + })) + log.Info(ctx, "Starting server at port 3004") + err := http.ListenAndServe(":3004", nil) + if err != nil { + log.Error(ctx, "error starting server", "err", err) + } + }() + <-gracefulShutdown } diff --git a/cmd/pending_publisher/main.go b/cmd/pending_publisher/main.go index 40dba78d1..fb9e8c29b 100644 --- a/cmd/pending_publisher/main.go +++ b/cmd/pending_publisher/main.go @@ -3,6 +3,7 @@ package main import ( "context" "math/big" + "net/http" "os" "os/signal" "syscall" @@ -190,6 +191,20 @@ func main() { } }(ctx) + go func() { + http.Handle("/status", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + _, err := w.Write([]byte("OK")) + if err != nil { + log.Error(ctx, "error writing response", "err", err) + } + })) + log.Info(ctx, "Starting server at port 3005") + err := http.ListenAndServe(":3005", nil) + if err != nil { + log.Error(ctx, "error starting server", "err", err) + } + }() + <-quit log.Info(ctx, "finishing app") cancel() diff --git a/infrastructure/local/docker-compose.yml b/infrastructure/local/docker-compose.yml index f370b2e8c..569934c81 100644 --- a/infrastructure/local/docker-compose.yml +++ b/infrastructure/local/docker-compose.yml @@ -52,6 +52,8 @@ services: build: context: ../../ dockerfile: ${DOCKER_FILE} + ports: + - "3004:3004" env_file: - ../../.env-api - ../../.env-issuer @@ -61,6 +63,8 @@ services: build: context: ../../ dockerfile: ${DOCKER_FILE} + ports: + - "3005:3005" env_file: - ../../.env-api - ../../.env-issuer