From d1fd65466ff4cda526fcb3ab45d8f199a1d73a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 19 Jul 2024 15:18:45 +0200 Subject: [PATCH 1/9] reuse default node id when registering services MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/fix-natsjskv-registry.md | 1 + ocis-pkg/natsjsregistry/registry.go | 20 ++++--------------- ocis-pkg/registry/service.go | 9 +++++---- ocis-pkg/service/grpc/service.go | 1 + services/app-provider/pkg/command/server.go | 2 +- services/app-registry/pkg/command/server.go | 2 +- services/auth-app/pkg/command/server.go | 2 +- services/auth-basic/pkg/command/server.go | 2 +- services/auth-bearer/pkg/command/server.go | 2 +- services/auth-machine/pkg/command/server.go | 2 +- services/auth-service/pkg/command/server.go | 2 +- .../collaboration/pkg/helpers/registration.go | 3 +-- services/frontend/pkg/command/server.go | 2 +- services/gateway/pkg/command/server.go | 2 +- .../graph/pkg/service/v0/graph_suite_test.go | 2 +- services/groups/pkg/command/server.go | 2 +- .../pkg/service/notification_suite_test.go | 2 +- services/ocm/pkg/command/server.go | 4 ++-- .../search/pkg/search/search_suite_test.go | 2 +- services/sharing/pkg/command/server.go | 2 +- .../storage-publiclink/pkg/command/server.go | 2 +- services/storage-shares/pkg/command/server.go | 2 +- services/storage-system/pkg/command/server.go | 4 ++-- services/storage-users/pkg/command/server.go | 2 +- .../storage-users/pkg/task/task_suite_test.go | 2 +- .../userlog/pkg/service/service_suit_test.go | 2 +- services/users/pkg/command/server.go | 2 +- 27 files changed, 36 insertions(+), 46 deletions(-) diff --git a/changelog/unreleased/fix-natsjskv-registry.md b/changelog/unreleased/fix-natsjskv-registry.md index bb8838fa50..f4a08600e8 100644 --- a/changelog/unreleased/fix-natsjskv-registry.md +++ b/changelog/unreleased/fix-natsjskv-registry.md @@ -2,6 +2,7 @@ Bugfix: Repair nats-js-kv registry The registry would always send traffic to only one pod. This is now fixed and load should be spread evenly. Also implements watcher method so the cache can use it. +https://github.com/owncloud/ocis/pull/9656 https://github.com/owncloud/ocis/pull/9662 https://github.com/owncloud/ocis/pull/9654 https://github.com/owncloud/ocis/pull/9620 diff --git a/ocis-pkg/natsjsregistry/registry.go b/ocis-pkg/natsjsregistry/registry.go index d9dcd5f932..b66896f168 100644 --- a/ocis-pkg/natsjsregistry/registry.go +++ b/ocis-pkg/natsjsregistry/registry.go @@ -12,9 +12,9 @@ import ( "time" natsjskv "github.com/go-micro/plugins/v4/store/nats-js-kv" - "github.com/google/uuid" "github.com/nats-io/nats.go" "go-micro.dev/v4/registry" + "go-micro.dev/v4/server" "go-micro.dev/v4/store" "go-micro.dev/v4/util/cmd" ) @@ -25,7 +25,7 @@ var ( _registryUsernameEnv = "MICRO_REGISTRY_AUTH_USERNAME" _registryPasswordEnv = "MICRO_REGISTRY_AUTH_PASSWORD" - _serviceDelimiter = "/" + _serviceDelimiter = "@" ) func init() { @@ -90,18 +90,12 @@ func (n *storeregistry) Register(s *registry.Service, opts ...registry.RegisterO o(&options) } - unique := uuid.New().String() - if s.Metadata == nil { - s.Metadata = make(map[string]string) - } - s.Metadata["uuid"] = unique - b, err := json.Marshal(s) if err != nil { return err } return n.store.Write(&store.Record{ - Key: s.Name + _serviceDelimiter + unique, + Key: s.Name + _serviceDelimiter + server.DefaultId, Value: b, Expiry: options.TTL, }) @@ -111,13 +105,7 @@ func (n *storeregistry) Register(s *registry.Service, opts ...registry.RegisterO func (n *storeregistry) Deregister(s *registry.Service, _ ...registry.DeregisterOption) error { n.lock.RLock() defer n.lock.RUnlock() - - var unique string - if s.Metadata != nil { - unique = s.Metadata["uuid"] - } - - return n.store.Delete(s.Name + _serviceDelimiter + unique) + return n.store.Delete(s.Name + _serviceDelimiter + server.DefaultId) } // GetService gets a specific service from the registry diff --git a/ocis-pkg/registry/service.go b/ocis-pkg/registry/service.go index da80a89122..65c62e8d26 100644 --- a/ocis-pkg/registry/service.go +++ b/ocis-pkg/registry/service.go @@ -7,10 +7,11 @@ import ( "strings" mRegistry "go-micro.dev/v4/registry" + "go-micro.dev/v4/server" "go-micro.dev/v4/util/addr" ) -func BuildGRPCService(serviceID, uuid, address string, version string) *mRegistry.Service { +func BuildGRPCService(serviceID, address string, version string) *mRegistry.Service { var host string var port int @@ -28,7 +29,7 @@ func BuildGRPCService(serviceID, uuid, address string, version string) *mRegistr } node := &mRegistry.Node{ - Id: serviceID + "-" + uuid, + Id: serviceID + "-" + server.DefaultId, Address: net.JoinHostPort(addr, fmt.Sprint(port)), Metadata: make(map[string]string), } @@ -46,7 +47,7 @@ func BuildGRPCService(serviceID, uuid, address string, version string) *mRegistr } } -func BuildHTTPService(serviceID, uuid, address string, version string) *mRegistry.Service { +func BuildHTTPService(serviceID, address string, version string) *mRegistry.Service { var host string var port int @@ -64,7 +65,7 @@ func BuildHTTPService(serviceID, uuid, address string, version string) *mRegistr } node := &mRegistry.Node{ - Id: serviceID + "-" + uuid, + Id: serviceID + "-" + server.DefaultId, Address: net.JoinHostPort(addr, fmt.Sprint(port)), Metadata: make(map[string]string), } diff --git a/ocis-pkg/service/grpc/service.go b/ocis-pkg/service/grpc/service.go index 3364c2194b..6afe731e2f 100644 --- a/ocis-pkg/service/grpc/service.go +++ b/ocis-pkg/service/grpc/service.go @@ -25,6 +25,7 @@ func NewServiceWithClient(client client.Client, opts ...Option) (Service, error) var mServer server.Server sopts := newOptions(opts...) tlsConfig := &tls.Config{} + if sopts.TLSEnabled { var cert tls.Certificate var err error diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 6259e7b849..35ec85888a 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -82,7 +82,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index 54bf524103..d540c4a5be 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -77,7 +77,7 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index afb3b54dc0..e13d1e0154 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -82,7 +82,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index 3a7aaf312a..c3b51a1b35 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -95,7 +95,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index 5646f63991..0fa78ee0db 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -82,7 +82,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index e19fb45f69..2e27fceb42 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -82,7 +82,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index 565f675747..ad28f3c79d 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -83,7 +83,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/collaboration/pkg/helpers/registration.go b/services/collaboration/pkg/helpers/registration.go index c4967dac7d..321a1947c1 100644 --- a/services/collaboration/pkg/helpers/registration.go +++ b/services/collaboration/pkg/helpers/registration.go @@ -8,7 +8,6 @@ import ( gatewayv1beta1 "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" "github.com/cs3org/reva/v2/pkg/mime" - "github.com/gofrs/uuid" "github.com/owncloud/ocis/v2/ocis-pkg/log" "github.com/owncloud/ocis/v2/ocis-pkg/registry" "github.com/owncloud/ocis/v2/ocis-pkg/version" @@ -19,7 +18,7 @@ import ( // There are no explicit requirements for the context, and it will be passed // without changes to the underlying RegisterService method. func RegisterOcisService(ctx context.Context, cfg *config.Config, logger log.Logger) error { - svc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name+"."+cfg.App.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + svc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name+"."+cfg.App.Name, cfg.GRPC.Addr, version.GetString()) return registry.RegisterService(ctx, svc, logger) } diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index a60e81153d..f7e6f9d7bd 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -86,7 +86,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.HTTP.Addr, version.GetString()) + httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, cfg.HTTP.Addr, version.GetString()) if err := registry.RegisterService(ctx, httpSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the http service") } diff --git a/services/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index ebbc7f7eb4..d34b1a9986 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/pkg/command/server.go @@ -77,7 +77,7 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/graph/pkg/service/v0/graph_suite_test.go b/services/graph/pkg/service/v0/graph_suite_test.go index 70dfcce145..8446bc9b69 100644 --- a/services/graph/pkg/service/v0/graph_suite_test.go +++ b/services/graph/pkg/service/v0/graph_suite_test.go @@ -12,7 +12,7 @@ import ( func init() { r := registry.GetRegistry(registry.Inmemory()) - service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "", "") + service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "") service.Nodes = []*mRegistry.Node{{ Address: "any", }} diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index 6690ebbb11..69b7215d0f 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -95,7 +95,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/notifications/pkg/service/notification_suite_test.go b/services/notifications/pkg/service/notification_suite_test.go index 7f282054fb..e045e43981 100644 --- a/services/notifications/pkg/service/notification_suite_test.go +++ b/services/notifications/pkg/service/notification_suite_test.go @@ -12,7 +12,7 @@ import ( func init() { r := registry.GetRegistry(registry.Inmemory()) - service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "", "") + service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "") service.Nodes = []*mRegistry.Node{{ Address: "any", }} diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index 1025d1ce73..43a2b7cdec 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -83,12 +83,12 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } - httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.HTTP.Addr, version.GetString()) + httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, cfg.HTTP.Addr, version.GetString()) if err := registry.RegisterService(ctx, httpSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the http service") } diff --git a/services/search/pkg/search/search_suite_test.go b/services/search/pkg/search/search_suite_test.go index 9422179fc5..ace85d9294 100644 --- a/services/search/pkg/search/search_suite_test.go +++ b/services/search/pkg/search/search_suite_test.go @@ -12,7 +12,7 @@ import ( func init() { r := registry.GetRegistry(registry.Inmemory()) - service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "", "") + service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "") service.Nodes = []*mRegistry.Node{{ Address: "any", }} diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index c0a89bfb97..bd50fff778 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -99,7 +99,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index b0829d4728..885c445384 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -82,7 +82,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index d7c186a1f1..e6603064bd 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -82,7 +82,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index 5424a456e9..7843c6b2b2 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -82,12 +82,12 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } - httpScv := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.HTTP.Addr, version.GetString()) + httpScv := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, cfg.HTTP.Addr, version.GetString()) if err := registry.RegisterService(ctx, httpScv, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the http service") } diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index 8a13bc78e5..770428e874 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -93,7 +93,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } diff --git a/services/storage-users/pkg/task/task_suite_test.go b/services/storage-users/pkg/task/task_suite_test.go index ac0c8a44b9..3837277808 100644 --- a/services/storage-users/pkg/task/task_suite_test.go +++ b/services/storage-users/pkg/task/task_suite_test.go @@ -12,7 +12,7 @@ import ( func init() { r := registry.GetRegistry(registry.Inmemory()) - service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "", "") + service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "") service.Nodes = []*mRegistry.Node{{ Address: "any", }} diff --git a/services/userlog/pkg/service/service_suit_test.go b/services/userlog/pkg/service/service_suit_test.go index 9da9654d4e..d049672b76 100644 --- a/services/userlog/pkg/service/service_suit_test.go +++ b/services/userlog/pkg/service/service_suit_test.go @@ -12,7 +12,7 @@ import ( func init() { r := registry.GetRegistry(registry.Inmemory()) - service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "", "") + service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "") service.Nodes = []*mRegistry.Node{{ Address: "any", }} diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index 100dea31b7..dac9cf08b9 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -95,7 +95,7 @@ func Server(cfg *config.Config) *cli.Command { sync.Trap(&gr, cancel) } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString()) + grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString()) if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil { logger.Fatal().Err(err).Msg("failed to register the grpc service") } From 06cc70f97811cab701c4c1a5771391f5c5d9d410 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Wed, 24 Jul 2024 12:22:15 +0200 Subject: [PATCH 2/9] feat(natsjsregistry): fix watcher feature Signed-off-by: jkoberg --- go.mod | 2 +- go.sum | 4 +- ocis-pkg/natsjsregistry/watcher.go | 36 +++++-------- .../plugins/v4/store/nats-js-kv/nats.go | 51 +++++++++++++++++-- vendor/modules.txt | 4 +- 5 files changed, 64 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index 5cc41cc4a6..a3026307e3 100644 --- a/go.mod +++ b/go.mod @@ -361,7 +361,7 @@ replace github.com/egirna/icap-client => github.com/fschade/icap-client v0.0.0-2 replace github.com/unrolled/secure => github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c -replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73 +replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6 // exclude the v2 line of go-sqlite3 which was released accidentally and prevents pulling in newer versions of go-sqlite3 // see https://github.com/mattn/go-sqlite3/issues/965 for more details diff --git a/go.sum b/go.sum index 6fc2e08da5..e44af375b0 100644 --- a/go.sum +++ b/go.sum @@ -1609,8 +1609,8 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73 h1:Cgg5BVWG99INUMX43nD5jhZgNzQJyFA0MvZkctNn0Lw= -github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY= +github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6 h1:NNXx1/XWR6Ryud6qNanwrl/JuRx2KdCW1jS2/Cf/TO8= +github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY= github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= diff --git a/ocis-pkg/natsjsregistry/watcher.go b/ocis-pkg/natsjsregistry/watcher.go index f5187358f3..0dc59f48db 100644 --- a/ocis-pkg/natsjsregistry/watcher.go +++ b/ocis-pkg/natsjsregistry/watcher.go @@ -1,21 +1,23 @@ package natsjsregistry import ( + "encoding/json" "errors" + natsjskv "github.com/go-micro/plugins/v4/store/nats-js-kv" "github.com/nats-io/nats.go" "go-micro.dev/v4/registry" ) // NatsWatcher is the watcher of the nats interface type NatsWatcher interface { - WatchAll(bucket string, opts ...nats.WatchOpt) (nats.KeyWatcher, error) + WatchAll(bucket string, opts ...nats.WatchOpt) (<-chan *natsjskv.StoreUpdate, func() error, error) } // Watcher is used to keep track of changes in the registry type Watcher struct { - watch nats.KeyWatcher - updates <-chan nats.KeyValueEntry + updates <-chan *natsjskv.StoreUpdate + stop func() error reg *storeregistry } @@ -26,14 +28,14 @@ func NewWatcher(s *storeregistry) (*Watcher, error) { return nil, errors.New("store does not implement watcher interface") } - watcher, err := w.WatchAll("service-registry") + watcher, stop, err := w.WatchAll("service-registry") if err != nil { return nil, err } return &Watcher{ - watch: watcher, - updates: watcher.Updates(), + updates: watcher, + stop: stop, reg: s, }, nil } @@ -45,30 +47,18 @@ func (w *Watcher) Next() (*registry.Result, error) { return nil, errors.New("watcher stopped") } - service, err := w.reg.getService(kve.Key()) - if err != nil { + var svc *registry.Service + if err := json.Unmarshal(kve.Value.Data, svc); err != nil { return nil, err } - var action string - switch kve.Operation() { - default: - action = "create" - case nats.KeyValuePut: - action = "create" - case nats.KeyValueDelete: - action = "delete" - case nats.KeyValuePurge: - action = "delete" - } - return ®istry.Result{ - Service: service, - Action: action, + Service: svc, + Action: kve.Action, }, nil } // Stop stops the watcher func (w *Watcher) Stop() { - _ = w.watch.Stop() + _ = w.stop() } diff --git a/vendor/github.com/go-micro/plugins/v4/store/nats-js-kv/nats.go b/vendor/github.com/go-micro/plugins/v4/store/nats-js-kv/nats.go index 4ffba417a9..280a6da131 100644 --- a/vendor/github.com/go-micro/plugins/v4/store/nats-js-kv/nats.go +++ b/vendor/github.com/go-micro/plugins/v4/store/nats-js-kv/nats.go @@ -335,22 +335,63 @@ func (n *natsStore) String() string { return "NATS JetStream KeyValueStore" } +// StoreUpdate is the update type for the store. +type StoreUpdate struct { + Value KeyValueEnvelope + Action string +} + // WatchAll exposes the watcher interface from the underlying JetStreamContext. -func (n *natsStore) WatchAll(bucket string, opts ...nats.WatchOpt) (nats.KeyWatcher, error) { +func (n *natsStore) WatchAll(bucket string, opts ...nats.WatchOpt) (<-chan *StoreUpdate, func() error, error) { if bucket == "" { - return nil, errors.New("multi bucket watching is not supported") + return nil, nil, errors.New("multi bucket watching is not supported") } if err := n.initConn(); err != nil { - return nil, err + return nil, nil, err } b, err := n.js.KeyValue(bucket) if err != nil { - return nil, errors.Wrap(err, "Failed to get bucket") + return nil, nil, errors.Wrap(err, "Failed to get bucket") } - return b.WatchAll(opts...) + w, err := b.WatchAll(opts...) + if err != nil { + return nil, nil, errors.Wrap(err, "Failed to watch bucket") + } + + ch := make(chan *StoreUpdate) + go func() { + for u := range w.Updates() { + if u == nil { + continue + } + + var action string + switch u.Operation() { + default: + action = u.Operation().String() + case nats.KeyValuePut: + action = "create" + case nats.KeyValueDelete: + action = "delete" + case nats.KeyValuePurge: + action = "delete" + } + + var kv KeyValueEnvelope + if err := json.Unmarshal(u.Value(), &kv); err != nil { + continue + } + ch <- &StoreUpdate{ + Value: kv, + Action: action, + } + } + }() + + return ch, w.Stop, nil } // thread safe way to initialize the connection. diff --git a/vendor/modules.txt b/vendor/modules.txt index 4b51469baf..9296c29054 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -963,7 +963,7 @@ github.com/go-micro/plugins/v4/server/http # github.com/go-micro/plugins/v4/store/nats-js v1.2.1-0.20231129143103-d72facc652f0 ## explicit; go 1.21 github.com/go-micro/plugins/v4/store/nats-js -# github.com/go-micro/plugins/v4/store/nats-js-kv v0.0.0-20231226212146-94a49ba3e06e => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73 +# github.com/go-micro/plugins/v4/store/nats-js-kv v0.0.0-20231226212146-94a49ba3e06e => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6 ## explicit; go 1.21 github.com/go-micro/plugins/v4/store/nats-js-kv # github.com/go-micro/plugins/v4/store/redis v1.2.1 @@ -2422,4 +2422,4 @@ stash.kopano.io/kgol/rndm # github.com/studio-b12/gowebdav => github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6 # github.com/egirna/icap-client => github.com/fschade/icap-client v0.0.0-20240123094924-5af178158eaf # github.com/unrolled/secure => github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c -# github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73 +# github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6 From d6045a74ea72214583624f2671d8a9744598fb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 24 Jul 2024 12:25:16 +0200 Subject: [PATCH 3/9] work on signals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- ocis/pkg/command/root.go | 6 +++++- ocis/pkg/command/server.go | 2 +- ocis/pkg/runtime/runtime.go | 6 ++++-- ocis/pkg/runtime/service/service.go | 8 ++++---- services/gateway/cmd/gateway/main.go | 7 ++++++- services/gateway/pkg/command/root.go | 2 +- services/gateway/pkg/command/server.go | 21 +++++++-------------- 7 files changed, 28 insertions(+), 24 deletions(-) diff --git a/ocis/pkg/command/root.go b/ocis/pkg/command/root.go index 2edf4a750f..666ee0544f 100644 --- a/ocis/pkg/command/root.go +++ b/ocis/pkg/command/root.go @@ -1,7 +1,10 @@ package command import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/ocis-pkg/clihelper" "github.com/owncloud/ocis/v2/ocis-pkg/config" @@ -25,5 +28,6 @@ func Execute() error { ) } - return app.Run(os.Args) + ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + return app.RunContext(ctx, os.Args) } diff --git a/ocis/pkg/command/server.go b/ocis/pkg/command/server.go index 108038ce72..f9c3aed070 100644 --- a/ocis/pkg/command/server.go +++ b/ocis/pkg/command/server.go @@ -21,7 +21,7 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { // Prefer the in-memory registry as the default when running in single-binary mode r := runtime.New(cfg) - return r.Start() + return r.Start(c.Context) }, } } diff --git a/ocis/pkg/runtime/runtime.go b/ocis/pkg/runtime/runtime.go index 32e6b8e1a9..49ce93c3b7 100644 --- a/ocis/pkg/runtime/runtime.go +++ b/ocis/pkg/runtime/runtime.go @@ -1,6 +1,8 @@ package runtime import ( + "context" + "github.com/owncloud/ocis/v2/ocis-pkg/config" "github.com/owncloud/ocis/v2/ocis/pkg/runtime/service" ) @@ -18,6 +20,6 @@ func New(cfg *config.Config) Runtime { } // Start rpc runtime -func (r *Runtime) Start() error { - return service.Start(service.WithConfig(r.c)) +func (r *Runtime) Start(ctx context.Context) error { + return service.Start(ctx, service.WithConfig(r.c)) } diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index d42604b7e6..eac779809d 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -96,7 +96,7 @@ type Service struct { // calls are done explicitly to loadFromEnv(). // Since this is the public constructor, options need to be added, at the moment only logging options // are supported in order to match the running OwnCloud services structured log. -func NewService(options ...Option) (*Service, error) { +func NewService(ctx context.Context, options ...Option) (*Service, error) { opts := NewOptions() for _, f := range options { @@ -109,7 +109,7 @@ func NewService(options ...Option) (*Service, error) { log.Level(opts.Config.Log.Level), ) - globalCtx, cancelGlobal := context.WithCancel(context.Background()) + globalCtx, cancelGlobal := context.WithCancel(ctx) s := &Service{ Services: make([]serviceFuncMap, len(_waitFuncs)), @@ -352,12 +352,12 @@ func NewService(options ...Option) (*Service, error) { // Start a rpc service. By default, the package scope Start will run all default services to provide with a working // oCIS instance. -func Start(o ...Option) error { +func Start(ctx context.Context, o ...Option) error { // Start the runtime. Most likely this was called ONLY by the `ocis server` subcommand, but since we cannot protect // from the caller, the previous statement holds truth. // prepare a new rpc Service struct. - s, err := NewService(o...) + s, err := NewService(ctx, o...) if err != nil { return err } diff --git a/services/gateway/cmd/gateway/main.go b/services/gateway/cmd/gateway/main.go index d22e804011..503e12de1c 100644 --- a/services/gateway/cmd/gateway/main.go +++ b/services/gateway/cmd/gateway/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/gateway/pkg/command" "github.com/owncloud/ocis/v2/services/gateway/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/gateway/pkg/command/root.go b/services/gateway/pkg/command/root.go index fcf6db18db..940a43259c 100644 --- a/services/gateway/pkg/command/root.go +++ b/services/gateway/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index d34b1a9986..9f556d556e 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/pkg/command/server.go @@ -37,7 +37,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -51,7 +51,9 @@ func Server(cfg *config.Config) *cli.Command { runtime.WithRegistry(reg), runtime.WithTraceProvider(traceProvider), ) - + logger.Info(). + Str("server", cfg.Service.Name). + Msg("reva runtime exited") return nil }, func(err error) { logger.Error(). @@ -60,7 +62,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( @@ -74,6 +75,9 @@ func Server(cfg *config.Config) *cli.Command { } gr.Add(debugServer.ListenAndServe, func(_ error) { + logger.Info(). + Str("server", cfg.Service.Name). + Msg("Shutting down debug erver") cancel() }) @@ -86,14 +90,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} From 7a22dfb6debdf5f6038377b8aa998fa9f9ef2d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 24 Jul 2024 13:26:50 +0200 Subject: [PATCH 4/9] NotifyContext when running services standalone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/activitylog/cmd/activitylog/main.go | 7 ++++++- services/antivirus/cmd/antivirus/main.go | 7 ++++++- services/app-provider/cmd/app-provider/main.go | 7 ++++++- services/app-registry/cmd/app-registry/main.go | 7 ++++++- services/audit/cmd/audit/main.go | 7 ++++++- services/auth-app/cmd/auth-app/main.go | 7 ++++++- services/auth-basic/cmd/auth-basic/main.go | 7 ++++++- services/auth-bearer/cmd/auth-bearer/main.go | 7 ++++++- services/auth-machine/cmd/auth-machine/main.go | 7 ++++++- services/auth-service/cmd/auth-service/main.go | 7 ++++++- services/clientlog/cmd/clientlog/main.go | 7 ++++++- services/eventhistory/cmd/eventhistory/main.go | 7 ++++++- services/frontend/cmd/frontend/main.go | 7 ++++++- services/graph/cmd/graph/main.go | 7 ++++++- services/groups/cmd/groups/main.go | 7 ++++++- services/idm/cmd/idm/main.go | 7 ++++++- services/idp/cmd/idp/main.go | 7 ++++++- services/invitations/cmd/invitations/main.go | 7 ++++++- services/nats/cmd/nats/main.go | 7 ++++++- services/notifications/cmd/notifications/main.go | 7 ++++++- services/ocdav/cmd/ocdav/main.go | 7 ++++++- services/ocm/cmd/ocm/main.go | 7 ++++++- services/ocs/cmd/ocs/main.go | 7 ++++++- services/policies/cmd/policies/main.go | 7 ++++++- services/postprocessing/cmd/postprocessing/main.go | 7 ++++++- services/proxy/cmd/proxy/main.go | 7 ++++++- services/search/cmd/search/main.go | 7 ++++++- services/settings/cmd/settings/main.go | 7 ++++++- services/sharing/cmd/sharing/main.go | 7 ++++++- services/sse/cmd/sse/main.go | 7 ++++++- services/storage-publiclink/cmd/storage-publiclink/main.go | 7 ++++++- services/storage-shares/cmd/storage-shares/main.go | 7 ++++++- services/storage-system/cmd/storage-system/main.go | 7 ++++++- services/storage-users/cmd/storage-users/main.go | 7 ++++++- services/store/cmd/store/main.go | 7 ++++++- services/thumbnails/cmd/thumbnails/main.go | 7 ++++++- services/userlog/cmd/userlog/main.go | 7 ++++++- services/users/cmd/user/main.go | 7 ++++++- services/web/cmd/web/main.go | 7 ++++++- services/webdav/cmd/webdav/main.go | 7 ++++++- services/webfinger/cmd/webfinger/main.go | 7 ++++++- 41 files changed, 246 insertions(+), 41 deletions(-) diff --git a/services/activitylog/cmd/activitylog/main.go b/services/activitylog/cmd/activitylog/main.go index d10204f4c8..a8555bd20d 100644 --- a/services/activitylog/cmd/activitylog/main.go +++ b/services/activitylog/cmd/activitylog/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/activitylog/pkg/command" "github.com/owncloud/ocis/v2/services/activitylog/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/antivirus/cmd/antivirus/main.go b/services/antivirus/cmd/antivirus/main.go index b37a1ca3ed..174e6fe3fb 100644 --- a/services/antivirus/cmd/antivirus/main.go +++ b/services/antivirus/cmd/antivirus/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/antivirus/pkg/command" "github.com/owncloud/ocis/v2/services/antivirus/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/app-provider/cmd/app-provider/main.go b/services/app-provider/cmd/app-provider/main.go index c4afd562c2..42b66fd9c0 100644 --- a/services/app-provider/cmd/app-provider/main.go +++ b/services/app-provider/cmd/app-provider/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/app-provider/pkg/command" "github.com/owncloud/ocis/v2/services/app-provider/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/app-registry/cmd/app-registry/main.go b/services/app-registry/cmd/app-registry/main.go index 6a9d91f7d6..e00af3f2ab 100644 --- a/services/app-registry/cmd/app-registry/main.go +++ b/services/app-registry/cmd/app-registry/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/app-registry/pkg/command" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/audit/cmd/audit/main.go b/services/audit/cmd/audit/main.go index f365e874ec..8b33880d6c 100644 --- a/services/audit/cmd/audit/main.go +++ b/services/audit/cmd/audit/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/audit/pkg/command" "github.com/owncloud/ocis/v2/services/audit/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/auth-app/cmd/auth-app/main.go b/services/auth-app/cmd/auth-app/main.go index 185d6eb9fd..d6cdb39e0c 100644 --- a/services/auth-app/cmd/auth-app/main.go +++ b/services/auth-app/cmd/auth-app/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/auth-app/pkg/command" "github.com/owncloud/ocis/v2/services/auth-app/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/auth-basic/cmd/auth-basic/main.go b/services/auth-basic/cmd/auth-basic/main.go index ec5af41edf..784d715be5 100644 --- a/services/auth-basic/cmd/auth-basic/main.go +++ b/services/auth-basic/cmd/auth-basic/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/command" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/auth-bearer/cmd/auth-bearer/main.go b/services/auth-bearer/cmd/auth-bearer/main.go index 8617701cfd..4bc12ab09c 100644 --- a/services/auth-bearer/cmd/auth-bearer/main.go +++ b/services/auth-bearer/cmd/auth-bearer/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/command" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/auth-machine/cmd/auth-machine/main.go b/services/auth-machine/cmd/auth-machine/main.go index 937b0b20cd..aeb79d5ccf 100644 --- a/services/auth-machine/cmd/auth-machine/main.go +++ b/services/auth-machine/cmd/auth-machine/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/command" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/auth-service/cmd/auth-service/main.go b/services/auth-service/cmd/auth-service/main.go index bcc7a625ec..81ce1579e9 100644 --- a/services/auth-service/cmd/auth-service/main.go +++ b/services/auth-service/cmd/auth-service/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/auth-service/pkg/command" "github.com/owncloud/ocis/v2/services/auth-service/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/clientlog/cmd/clientlog/main.go b/services/clientlog/cmd/clientlog/main.go index ce0d4a4aff..cdd91f273a 100644 --- a/services/clientlog/cmd/clientlog/main.go +++ b/services/clientlog/cmd/clientlog/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/clientlog/pkg/command" "github.com/owncloud/ocis/v2/services/clientlog/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/eventhistory/cmd/eventhistory/main.go b/services/eventhistory/cmd/eventhistory/main.go index d2172949bc..4a1d3f8701 100644 --- a/services/eventhistory/cmd/eventhistory/main.go +++ b/services/eventhistory/cmd/eventhistory/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/eventhistory/pkg/command" "github.com/owncloud/ocis/v2/services/eventhistory/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/frontend/cmd/frontend/main.go b/services/frontend/cmd/frontend/main.go index cbdc5dac51..8e12e7761a 100644 --- a/services/frontend/cmd/frontend/main.go +++ b/services/frontend/cmd/frontend/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/frontend/pkg/command" "github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/graph/cmd/graph/main.go b/services/graph/cmd/graph/main.go index 7844daa6af..0775fcb487 100644 --- a/services/graph/cmd/graph/main.go +++ b/services/graph/cmd/graph/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/graph/pkg/command" "github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/groups/cmd/groups/main.go b/services/groups/cmd/groups/main.go index 2172fc8450..d13447d496 100644 --- a/services/groups/cmd/groups/main.go +++ b/services/groups/cmd/groups/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/groups/pkg/command" "github.com/owncloud/ocis/v2/services/groups/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/idm/cmd/idm/main.go b/services/idm/cmd/idm/main.go index f30202e587..ab6af89f2b 100644 --- a/services/idm/cmd/idm/main.go +++ b/services/idm/cmd/idm/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/idm/pkg/command" "github.com/owncloud/ocis/v2/services/idm/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/idp/cmd/idp/main.go b/services/idp/cmd/idp/main.go index 174283c909..d3def5ab1c 100644 --- a/services/idp/cmd/idp/main.go +++ b/services/idp/cmd/idp/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/idp/pkg/command" "github.com/owncloud/ocis/v2/services/idp/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/invitations/cmd/invitations/main.go b/services/invitations/cmd/invitations/main.go index 3290c0b306..86da31fcb1 100644 --- a/services/invitations/cmd/invitations/main.go +++ b/services/invitations/cmd/invitations/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/invitations/pkg/command" "github.com/owncloud/ocis/v2/services/invitations/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/nats/cmd/nats/main.go b/services/nats/cmd/nats/main.go index 4b5803ac78..2e75edad3d 100644 --- a/services/nats/cmd/nats/main.go +++ b/services/nats/cmd/nats/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/nats/pkg/command" "github.com/owncloud/ocis/v2/services/nats/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/notifications/cmd/notifications/main.go b/services/notifications/cmd/notifications/main.go index 5d5752af38..1836a24f85 100644 --- a/services/notifications/cmd/notifications/main.go +++ b/services/notifications/cmd/notifications/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/notifications/pkg/command" "github.com/owncloud/ocis/v2/services/notifications/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/ocdav/cmd/ocdav/main.go b/services/ocdav/cmd/ocdav/main.go index 9875027bdb..964af1667c 100644 --- a/services/ocdav/cmd/ocdav/main.go +++ b/services/ocdav/cmd/ocdav/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/ocdav/pkg/command" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/ocm/cmd/ocm/main.go b/services/ocm/cmd/ocm/main.go index 6ac3d5a577..6a4b7926d8 100644 --- a/services/ocm/cmd/ocm/main.go +++ b/services/ocm/cmd/ocm/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/ocm/pkg/command" "github.com/owncloud/ocis/v2/services/ocm/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/ocs/cmd/ocs/main.go b/services/ocs/cmd/ocs/main.go index a2b9021ead..8ae7d02622 100644 --- a/services/ocs/cmd/ocs/main.go +++ b/services/ocs/cmd/ocs/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/ocs/pkg/command" "github.com/owncloud/ocis/v2/services/ocs/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/policies/cmd/policies/main.go b/services/policies/cmd/policies/main.go index db0896e407..09abb5e85e 100644 --- a/services/policies/cmd/policies/main.go +++ b/services/policies/cmd/policies/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/policies/pkg/command" "github.com/owncloud/ocis/v2/services/policies/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/postprocessing/cmd/postprocessing/main.go b/services/postprocessing/cmd/postprocessing/main.go index ddc191e3a3..e42d50ccdf 100644 --- a/services/postprocessing/cmd/postprocessing/main.go +++ b/services/postprocessing/cmd/postprocessing/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/postprocessing/pkg/command" "github.com/owncloud/ocis/v2/services/postprocessing/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/proxy/cmd/proxy/main.go b/services/proxy/cmd/proxy/main.go index 7db75b5de0..9c51a443e4 100644 --- a/services/proxy/cmd/proxy/main.go +++ b/services/proxy/cmd/proxy/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/proxy/pkg/command" "github.com/owncloud/ocis/v2/services/proxy/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/search/cmd/search/main.go b/services/search/cmd/search/main.go index 70103e7bf0..807b664273 100644 --- a/services/search/cmd/search/main.go +++ b/services/search/cmd/search/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/search/pkg/command" "github.com/owncloud/ocis/v2/services/search/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/settings/cmd/settings/main.go b/services/settings/cmd/settings/main.go index 1e21338dd8..8833af4bbe 100644 --- a/services/settings/cmd/settings/main.go +++ b/services/settings/cmd/settings/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/settings/pkg/command" "github.com/owncloud/ocis/v2/services/settings/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/sharing/cmd/sharing/main.go b/services/sharing/cmd/sharing/main.go index 54e0996e3f..cb5b4e5cca 100644 --- a/services/sharing/cmd/sharing/main.go +++ b/services/sharing/cmd/sharing/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/sharing/pkg/command" "github.com/owncloud/ocis/v2/services/sharing/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/sse/cmd/sse/main.go b/services/sse/cmd/sse/main.go index 8bd438f114..9b31eea528 100644 --- a/services/sse/cmd/sse/main.go +++ b/services/sse/cmd/sse/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/sse/pkg/command" "github.com/owncloud/ocis/v2/services/sse/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/storage-publiclink/cmd/storage-publiclink/main.go b/services/storage-publiclink/cmd/storage-publiclink/main.go index 6d2415a007..e1637605c6 100644 --- a/services/storage-publiclink/cmd/storage-publiclink/main.go +++ b/services/storage-publiclink/cmd/storage-publiclink/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/command" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/storage-shares/cmd/storage-shares/main.go b/services/storage-shares/cmd/storage-shares/main.go index 8a8f9336be..472cf04c8f 100644 --- a/services/storage-shares/cmd/storage-shares/main.go +++ b/services/storage-shares/cmd/storage-shares/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/command" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/storage-system/cmd/storage-system/main.go b/services/storage-system/cmd/storage-system/main.go index d9242ea057..761e1ab233 100644 --- a/services/storage-system/cmd/storage-system/main.go +++ b/services/storage-system/cmd/storage-system/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/storage-system/pkg/command" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/storage-users/cmd/storage-users/main.go b/services/storage-users/cmd/storage-users/main.go index c3c7bc7e3f..142e5a4413 100644 --- a/services/storage-users/cmd/storage-users/main.go +++ b/services/storage-users/cmd/storage-users/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/storage-users/pkg/command" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/store/cmd/store/main.go b/services/store/cmd/store/main.go index ecf42e8193..3bbf8cff80 100644 --- a/services/store/cmd/store/main.go +++ b/services/store/cmd/store/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/store/pkg/command" "github.com/owncloud/ocis/v2/services/store/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/thumbnails/cmd/thumbnails/main.go b/services/thumbnails/cmd/thumbnails/main.go index f0a86f58bf..9f3cce9566 100644 --- a/services/thumbnails/cmd/thumbnails/main.go +++ b/services/thumbnails/cmd/thumbnails/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/command" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/userlog/cmd/userlog/main.go b/services/userlog/cmd/userlog/main.go index efdb7ae4b8..2df9a2a98f 100644 --- a/services/userlog/cmd/userlog/main.go +++ b/services/userlog/cmd/userlog/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/userlog/pkg/command" "github.com/owncloud/ocis/v2/services/userlog/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/users/cmd/user/main.go b/services/users/cmd/user/main.go index cae358d3c0..6d69289324 100644 --- a/services/users/cmd/user/main.go +++ b/services/users/cmd/user/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/users/pkg/command" "github.com/owncloud/ocis/v2/services/users/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/web/cmd/web/main.go b/services/web/cmd/web/main.go index 9974c37fc9..2ee45f9eeb 100644 --- a/services/web/cmd/web/main.go +++ b/services/web/cmd/web/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/web/pkg/command" "github.com/owncloud/ocis/v2/services/web/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/webdav/cmd/webdav/main.go b/services/webdav/cmd/webdav/main.go index 84449ec2e3..08d0bdbbe4 100644 --- a/services/webdav/cmd/webdav/main.go +++ b/services/webdav/cmd/webdav/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/webdav/pkg/command" "github.com/owncloud/ocis/v2/services/webdav/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } diff --git a/services/webfinger/cmd/webfinger/main.go b/services/webfinger/cmd/webfinger/main.go index f370d1c9e9..b67f9ba63e 100644 --- a/services/webfinger/cmd/webfinger/main.go +++ b/services/webfinger/cmd/webfinger/main.go @@ -1,14 +1,19 @@ package main import ( + "context" "os" + "os/signal" + "syscall" "github.com/owncloud/ocis/v2/services/webfinger/pkg/command" "github.com/owncloud/ocis/v2/services/webfinger/pkg/config/defaults" ) func main() { - if err := command.Execute(defaults.DefaultConfig()); err != nil { + cfg := defaults.DefaultConfig() + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + if err := command.Execute(cfg); err != nil { os.Exit(1) } } From 008f379a0199279f1af58059d5f91b75dab2747e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 24 Jul 2024 13:30:42 +0200 Subject: [PATCH 5/9] pass config context when running apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/activitylog/pkg/command/root.go | 2 +- services/antivirus/pkg/command/root.go | 2 +- services/app-provider/pkg/command/root.go | 2 +- services/app-registry/pkg/command/root.go | 2 +- services/audit/pkg/command/root.go | 2 +- services/auth-app/pkg/command/root.go | 2 +- services/auth-basic/pkg/command/root.go | 2 +- services/auth-bearer/pkg/command/root.go | 2 +- services/auth-machine/pkg/command/root.go | 2 +- services/auth-service/pkg/command/root.go | 2 +- services/clientlog/pkg/command/root.go | 2 +- services/collaboration/pkg/command/root.go | 2 +- services/eventhistory/pkg/command/root.go | 2 +- services/frontend/pkg/command/root.go | 2 +- services/graph/pkg/command/root.go | 2 +- services/groups/pkg/command/root.go | 2 +- services/idm/pkg/command/root.go | 2 +- services/idp/pkg/command/root.go | 2 +- services/invitations/pkg/command/root.go | 2 +- services/nats/pkg/command/root.go | 2 +- services/notifications/pkg/command/root.go | 2 +- services/ocdav/pkg/command/root.go | 2 +- services/ocm/pkg/command/root.go | 2 +- services/ocs/pkg/command/root.go | 2 +- services/policies/pkg/command/root.go | 2 +- services/postprocessing/pkg/command/root.go | 2 +- services/proxy/pkg/command/root.go | 2 +- services/search/pkg/command/root.go | 2 +- services/settings/pkg/command/root.go | 2 +- services/sharing/pkg/command/root.go | 2 +- services/sse/pkg/command/root.go | 2 +- services/storage-publiclink/pkg/command/root.go | 2 +- services/storage-shares/pkg/command/root.go | 2 +- services/storage-system/pkg/command/root.go | 2 +- services/storage-users/pkg/command/root.go | 2 +- services/store/pkg/command/root.go | 2 +- services/thumbnails/pkg/command/root.go | 2 +- services/userlog/pkg/command/root.go | 2 +- services/users/pkg/command/root.go | 2 +- services/web/pkg/command/root.go | 2 +- services/webdav/pkg/command/root.go | 2 +- services/webfinger/pkg/command/root.go | 2 +- 42 files changed, 42 insertions(+), 42 deletions(-) diff --git a/services/activitylog/pkg/command/root.go b/services/activitylog/pkg/command/root.go index 518d6309b3..0874c93890 100644 --- a/services/activitylog/pkg/command/root.go +++ b/services/activitylog/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/antivirus/pkg/command/root.go b/services/antivirus/pkg/command/root.go index 2884482748..4683d3bc52 100644 --- a/services/antivirus/pkg/command/root.go +++ b/services/antivirus/pkg/command/root.go @@ -25,5 +25,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/app-provider/pkg/command/root.go b/services/app-provider/pkg/command/root.go index d7bbe2bb4f..42ac00c494 100644 --- a/services/app-provider/pkg/command/root.go +++ b/services/app-provider/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/app-registry/pkg/command/root.go b/services/app-registry/pkg/command/root.go index 9f20d6051a..41582af228 100644 --- a/services/app-registry/pkg/command/root.go +++ b/services/app-registry/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/audit/pkg/command/root.go b/services/audit/pkg/command/root.go index abe6054a56..c52fd880de 100644 --- a/services/audit/pkg/command/root.go +++ b/services/audit/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/auth-app/pkg/command/root.go b/services/auth-app/pkg/command/root.go index f1ba83b36e..a3c2c87df0 100644 --- a/services/auth-app/pkg/command/root.go +++ b/services/auth-app/pkg/command/root.go @@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/auth-basic/pkg/command/root.go b/services/auth-basic/pkg/command/root.go index cb53a0a667..46823bc174 100644 --- a/services/auth-basic/pkg/command/root.go +++ b/services/auth-basic/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/auth-bearer/pkg/command/root.go b/services/auth-bearer/pkg/command/root.go index c923e706fb..c22b4f9ae3 100644 --- a/services/auth-bearer/pkg/command/root.go +++ b/services/auth-bearer/pkg/command/root.go @@ -33,7 +33,7 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } // SutureService allows for the accounts command to be embedded and supervised by a suture supervisor tree. diff --git a/services/auth-machine/pkg/command/root.go b/services/auth-machine/pkg/command/root.go index fe153cd784..733789b979 100644 --- a/services/auth-machine/pkg/command/root.go +++ b/services/auth-machine/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/auth-service/pkg/command/root.go b/services/auth-service/pkg/command/root.go index 2fd57dd7ad..f37d4584c7 100644 --- a/services/auth-service/pkg/command/root.go +++ b/services/auth-service/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/clientlog/pkg/command/root.go b/services/clientlog/pkg/command/root.go index 389caf1bb2..ca9b26166b 100644 --- a/services/clientlog/pkg/command/root.go +++ b/services/clientlog/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/collaboration/pkg/command/root.go b/services/collaboration/pkg/command/root.go index 31fe6db63f..11035c8007 100644 --- a/services/collaboration/pkg/command/root.go +++ b/services/collaboration/pkg/command/root.go @@ -25,5 +25,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/eventhistory/pkg/command/root.go b/services/eventhistory/pkg/command/root.go index 683c716a30..a1d27a5636 100644 --- a/services/eventhistory/pkg/command/root.go +++ b/services/eventhistory/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/frontend/pkg/command/root.go b/services/frontend/pkg/command/root.go index ab4fd04523..0e906f15ea 100644 --- a/services/frontend/pkg/command/root.go +++ b/services/frontend/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/graph/pkg/command/root.go b/services/graph/pkg/command/root.go index 5c9fae2894..dd967ffbed 100644 --- a/services/graph/pkg/command/root.go +++ b/services/graph/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Usage: "Serve Graph API for oCIS", Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/groups/pkg/command/root.go b/services/groups/pkg/command/root.go index fdc14e6856..ba2a991b40 100644 --- a/services/groups/pkg/command/root.go +++ b/services/groups/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/idm/pkg/command/root.go b/services/idm/pkg/command/root.go index 85134a4375..6e6c9c4dc8 100644 --- a/services/idm/pkg/command/root.go +++ b/services/idm/pkg/command/root.go @@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/idp/pkg/command/root.go b/services/idp/pkg/command/root.go index 724620d7da..b6707989cd 100644 --- a/services/idp/pkg/command/root.go +++ b/services/idp/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/invitations/pkg/command/root.go b/services/invitations/pkg/command/root.go index aa8c993ab3..7425baf0d3 100644 --- a/services/invitations/pkg/command/root.go +++ b/services/invitations/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/nats/pkg/command/root.go b/services/nats/pkg/command/root.go index 067bd39cd5..483d91b63c 100644 --- a/services/nats/pkg/command/root.go +++ b/services/nats/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/notifications/pkg/command/root.go b/services/notifications/pkg/command/root.go index aa048245a0..2833e622ed 100644 --- a/services/notifications/pkg/command/root.go +++ b/services/notifications/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/ocdav/pkg/command/root.go b/services/ocdav/pkg/command/root.go index 5b1afc5b30..6dd8518683 100644 --- a/services/ocdav/pkg/command/root.go +++ b/services/ocdav/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/ocm/pkg/command/root.go b/services/ocm/pkg/command/root.go index 7187fe5273..e524c73bd3 100644 --- a/services/ocm/pkg/command/root.go +++ b/services/ocm/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/ocs/pkg/command/root.go b/services/ocs/pkg/command/root.go index 569ff06ab4..1d2d38d881 100644 --- a/services/ocs/pkg/command/root.go +++ b/services/ocs/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/policies/pkg/command/root.go b/services/policies/pkg/command/root.go index 368ca7657c..5926061c53 100644 --- a/services/policies/pkg/command/root.go +++ b/services/policies/pkg/command/root.go @@ -25,5 +25,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/postprocessing/pkg/command/root.go b/services/postprocessing/pkg/command/root.go index f4a2086320..1e9796445f 100644 --- a/services/postprocessing/pkg/command/root.go +++ b/services/postprocessing/pkg/command/root.go @@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/proxy/pkg/command/root.go b/services/proxy/pkg/command/root.go index 65d32b5753..b918424d6d 100644 --- a/services/proxy/pkg/command/root.go +++ b/services/proxy/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/search/pkg/command/root.go b/services/search/pkg/command/root.go index e850b3612f..f0f9d05b71 100644 --- a/services/search/pkg/command/root.go +++ b/services/search/pkg/command/root.go @@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error { Usage: "Serve search API for oCIS", Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/settings/pkg/command/root.go b/services/settings/pkg/command/root.go index 641cf491c6..d9679de410 100644 --- a/services/settings/pkg/command/root.go +++ b/services/settings/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/sharing/pkg/command/root.go b/services/sharing/pkg/command/root.go index fba13bf905..4330a939b4 100644 --- a/services/sharing/pkg/command/root.go +++ b/services/sharing/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/sse/pkg/command/root.go b/services/sse/pkg/command/root.go index f3a6e4b276..290cc70011 100644 --- a/services/sse/pkg/command/root.go +++ b/services/sse/pkg/command/root.go @@ -26,5 +26,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/storage-publiclink/pkg/command/root.go b/services/storage-publiclink/pkg/command/root.go index 9ca05cc710..a3822e8b0e 100644 --- a/services/storage-publiclink/pkg/command/root.go +++ b/services/storage-publiclink/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/storage-shares/pkg/command/root.go b/services/storage-shares/pkg/command/root.go index fd36affa1e..2295b539da 100644 --- a/services/storage-shares/pkg/command/root.go +++ b/services/storage-shares/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/storage-system/pkg/command/root.go b/services/storage-system/pkg/command/root.go index 92b6e757af..a9786726f1 100644 --- a/services/storage-system/pkg/command/root.go +++ b/services/storage-system/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/storage-users/pkg/command/root.go b/services/storage-users/pkg/command/root.go index 777ec6f2f6..d24d37a6c1 100644 --- a/services/storage-users/pkg/command/root.go +++ b/services/storage-users/pkg/command/root.go @@ -32,5 +32,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/store/pkg/command/root.go b/services/store/pkg/command/root.go index 8e208dba5b..d105b28f9f 100644 --- a/services/store/pkg/command/root.go +++ b/services/store/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/thumbnails/pkg/command/root.go b/services/thumbnails/pkg/command/root.go index 8ddf1c23d6..2e12c42c3b 100644 --- a/services/thumbnails/pkg/command/root.go +++ b/services/thumbnails/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/userlog/pkg/command/root.go b/services/userlog/pkg/command/root.go index dd80e5acb6..8b8d1b1a5c 100644 --- a/services/userlog/pkg/command/root.go +++ b/services/userlog/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/users/pkg/command/root.go b/services/users/pkg/command/root.go index e0039b1c39..8952e628aa 100644 --- a/services/users/pkg/command/root.go +++ b/services/users/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/web/pkg/command/root.go b/services/web/pkg/command/root.go index 91a648c1a2..6f91fb895f 100644 --- a/services/web/pkg/command/root.go +++ b/services/web/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/webdav/pkg/command/root.go b/services/webdav/pkg/command/root.go index 8a1d46b23a..e2d6cf9f7f 100644 --- a/services/webdav/pkg/command/root.go +++ b/services/webdav/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } diff --git a/services/webfinger/pkg/command/root.go b/services/webfinger/pkg/command/root.go index 4d553a2655..a6d30c53cf 100644 --- a/services/webfinger/pkg/command/root.go +++ b/services/webfinger/pkg/command/root.go @@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error { Commands: GetCommands(cfg), }) - return app.Run(os.Args) + return app.RunContext(cfg.Context, os.Args) } From a96203786fc725073a52a912faa3d1bd990dabd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 24 Jul 2024 13:33:57 +0200 Subject: [PATCH 6/9] replace defineContext with context from app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/app-provider/pkg/command/server.go | 13 +------------ services/app-registry/pkg/command/server.go | 13 +------------ services/auth-app/pkg/command/server.go | 15 ++------------- services/auth-basic/pkg/command/server.go | 13 +------------ services/auth-bearer/pkg/command/server.go | 13 +------------ services/auth-machine/pkg/command/server.go | 13 +------------ services/auth-service/pkg/command/server.go | 13 +------------ services/frontend/pkg/command/server.go | 13 +------------ services/groups/pkg/command/server.go | 13 +------------ services/ocdav/pkg/command/server.go | 13 +------------ services/ocm/pkg/command/server.go | 13 +------------ services/sharing/pkg/command/server.go | 13 +------------ services/storage-publiclink/pkg/command/server.go | 13 +------------ services/storage-shares/pkg/command/server.go | 13 +------------ services/storage-system/pkg/command/server.go | 13 +------------ services/storage-users/pkg/command/server.go | 13 +------------ services/users/pkg/command/server.go | 13 +------------ 17 files changed, 18 insertions(+), 205 deletions(-) diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 35ec85888a..ff001ad9ad 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -91,14 +91,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index d540c4a5be..61a27a3c0b 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -37,7 +37,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -86,14 +86,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index e13d1e0154..3ba0674a85 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -31,14 +31,14 @@ func Server(cfg *config.Config) *cli.Command { Before: func(_ *cli.Context) error { return configlog.ReturnFatal(parser.ParseConfig(cfg)) }, - Action: func(_ *cli.Context) error { + Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -91,14 +91,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index c3b51a1b35..dd0f247e59 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -39,7 +39,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -104,14 +104,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index 0fa78ee0db..d2e8863486 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -91,14 +91,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 2e27fceb42..070b00a6df 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -91,14 +91,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index ad28f3c79d..05e0ca124d 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -92,14 +92,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index f7e6f9d7bd..83c011be6d 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -102,14 +102,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index 69b7215d0f..3bdf022704 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -39,7 +39,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -104,14 +104,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 33bb9b3226..e7573be410 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -36,7 +36,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -127,14 +127,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index 43a2b7cdec..6dd6f8f2fc 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -97,14 +97,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index bd50fff778..d7e4ba47de 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -39,7 +39,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -108,14 +108,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 885c445384..3c3bacc701 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -91,14 +91,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index e6603064bd..1e2a8745fb 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -91,14 +91,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index 7843c6b2b2..f09e2f1f6a 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -96,14 +96,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index 770428e874..444ce0a6dd 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -40,7 +40,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -128,14 +128,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index dac9cf08b9..2b96aac547 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -39,7 +39,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := defineContext(cfg) + ctx, cancel := context.WithCancel(c.Context) defer cancel() @@ -104,14 +104,3 @@ func Server(cfg *config.Config) *cli.Command { }, } } - -// defineContext sets the context for the service. If there is a context configured it will create a new child from it, -// if not, it will create a root context that can be cancelled. -func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) { - return func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() -} From 9d1515e8fcd34c098d2bece9c9ec34aa2ff07081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 24 Jul 2024 13:37:39 +0200 Subject: [PATCH 7/9] rely on context from app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/activitylog/pkg/command/server.go | 7 +------ services/antivirus/pkg/command/server.go | 9 ++------- services/audit/pkg/command/server.go | 7 +------ services/clientlog/pkg/command/server.go | 7 +------ services/collaboration/pkg/command/server.go | 7 +------ services/eventhistory/pkg/command/server.go | 9 ++------- services/graph/pkg/command/server.go | 7 +------ services/idm/pkg/command/resetpw.go | 7 +------ services/idm/pkg/command/server.go | 7 +------ services/idp/pkg/command/server.go | 9 ++------- services/invitations/pkg/command/server.go | 9 ++------- services/nats/pkg/command/server.go | 7 +------ services/notifications/pkg/command/server.go | 8 +------- services/ocs/pkg/command/server.go | 9 ++------- services/policies/pkg/command/server.go | 9 ++------- services/postprocessing/pkg/command/server.go | 12 +++--------- services/proxy/pkg/command/server.go | 7 +------ services/search/pkg/command/server.go | 7 +------ services/settings/pkg/command/server.go | 7 +------ services/sse/pkg/command/server.go | 9 ++------- services/store/pkg/command/server.go | 12 ++---------- services/thumbnails/pkg/command/server.go | 11 +++-------- services/userlog/pkg/command/server.go | 7 +------ services/web/pkg/command/server.go | 11 +++-------- services/webdav/pkg/command/server.go | 9 ++------- services/webfinger/pkg/command/server.go | 9 ++------- 26 files changed, 42 insertions(+), 177 deletions(-) diff --git a/services/activitylog/pkg/command/server.go b/services/activitylog/pkg/command/server.go index e6854065c8..4f9d7d1d4d 100644 --- a/services/activitylog/pkg/command/server.go +++ b/services/activitylog/pkg/command/server.go @@ -61,12 +61,7 @@ func Server(cfg *config.Config) *cli.Command { } gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) mtrcs := metrics.New() mtrcs.BuildInfo.WithLabelValues(version.GetString()).Set(1) diff --git a/services/antivirus/pkg/command/server.go b/services/antivirus/pkg/command/server.go index 32e2fd8b44..0acbd87321 100644 --- a/services/antivirus/pkg/command/server.go +++ b/services/antivirus/pkg/command/server.go @@ -29,13 +29,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - logger = log.NewLogger( + ctx, cancel = context.WithCancel(c.Context) + logger = log.NewLogger( log.Name(cfg.Service.Name), log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), diff --git a/services/audit/pkg/command/server.go b/services/audit/pkg/command/server.go index 6c55e638c1..aeaf01128f 100644 --- a/services/audit/pkg/command/server.go +++ b/services/audit/pkg/command/server.go @@ -34,12 +34,7 @@ func Server(cfg *config.Config) *cli.Command { gr = run.Group{} logger = logging.Configure(cfg.Service.Name, cfg.Log) - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel = context.WithCancel(c.Context) ) defer cancel() diff --git a/services/clientlog/pkg/command/server.go b/services/clientlog/pkg/command/server.go index 29cfaf6cf8..b87ec8f231 100644 --- a/services/clientlog/pkg/command/server.go +++ b/services/clientlog/pkg/command/server.go @@ -62,12 +62,7 @@ func Server(cfg *config.Config) *cli.Command { } gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) mtrcs := metrics.New() mtrcs.BuildInfo.WithLabelValues(version.GetString()).Set(1) diff --git a/services/collaboration/pkg/command/server.go b/services/collaboration/pkg/command/server.go index 5732c55890..799448d4cf 100644 --- a/services/collaboration/pkg/command/server.go +++ b/services/collaboration/pkg/command/server.go @@ -36,12 +36,7 @@ func Server(cfg *config.Config) *cli.Command { } gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) defer cancel() // prepare components diff --git a/services/eventhistory/pkg/command/server.go b/services/eventhistory/pkg/command/server.go index 197e07ae8b..1c9146aa75 100644 --- a/services/eventhistory/pkg/command/server.go +++ b/services/eventhistory/pkg/command/server.go @@ -47,13 +47,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - m = metrics.New() + ctx, cancel = context.WithCancel(c.Context) + m = metrics.New() ) defer cancel() diff --git a/services/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index 2c547aefeb..0cde2d4db4 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -35,12 +35,7 @@ func Server(cfg *config.Config) *cli.Command { } gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) mtrcs := metrics.New() defer cancel() diff --git a/services/idm/pkg/command/resetpw.go b/services/idm/pkg/command/resetpw.go index 0fd204c501..bdc3704486 100644 --- a/services/idm/pkg/command/resetpw.go +++ b/services/idm/pkg/command/resetpw.go @@ -40,12 +40,7 @@ func ResetPassword(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) defer cancel() return resetPassword(ctx, logger, cfg, c.String("user-name")) diff --git a/services/idm/pkg/command/server.go b/services/idm/pkg/command/server.go index 048ef8d3b6..16e8a081fe 100644 --- a/services/idm/pkg/command/server.go +++ b/services/idm/pkg/command/server.go @@ -40,12 +40,7 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} logger = logging.Configure(cfg.Service.Name, cfg.Log) - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel = context.WithCancel(c.Context) ) defer cancel() diff --git a/services/idp/pkg/command/server.go b/services/idp/pkg/command/server.go index 48f431f592..78f658f146 100644 --- a/services/idp/pkg/command/server.go +++ b/services/idp/pkg/command/server.go @@ -56,13 +56,8 @@ func Server(cfg *config.Config) *cli.Command { } var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - metrics = metrics.New() + ctx, cancel = context.WithCancel(c.Context) + metrics = metrics.New() ) defer cancel() diff --git a/services/invitations/pkg/command/server.go b/services/invitations/pkg/command/server.go index 01000c7d72..183627c2d2 100644 --- a/services/invitations/pkg/command/server.go +++ b/services/invitations/pkg/command/server.go @@ -37,13 +37,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - metrics = metrics.New(metrics.Logger(logger)) + ctx, cancel = context.WithCancel(c.Context) + metrics = metrics.New(metrics.Logger(logger)) ) defer cancel() diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index e118d43312..f7b00f2934 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -33,12 +33,7 @@ func Server(cfg *config.Config) *cli.Command { logger := logging.Configure(cfg.Service.Name, cfg.Log) gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) defer cancel() diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index 55b3c7ad3c..0b635a2a2a 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -53,13 +53,7 @@ func Server(cfg *config.Config) *cli.Command { gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - + ctx, cancel := context.WithCancel(c.Context) defer cancel() { diff --git a/services/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index cdb2311633..4a70945a8c 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/pkg/command/server.go @@ -42,13 +42,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - metrics = metrics.New() + ctx, cancel = context.WithCancel(c.Context) + metrics = metrics.New() ) defer cancel() diff --git a/services/policies/pkg/command/server.go b/services/policies/pkg/command/server.go index 6f4729f691..5719335ae2 100644 --- a/services/policies/pkg/command/server.go +++ b/services/policies/pkg/command/server.go @@ -35,13 +35,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - logger = log.NewLogger( + ctx, cancel = context.WithCancel(c.Context) + logger = log.NewLogger( log.Name(cfg.Service.Name), log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), diff --git a/services/postprocessing/pkg/command/server.go b/services/postprocessing/pkg/command/server.go index f5033c1234..5ccf65e6c1 100644 --- a/services/postprocessing/pkg/command/server.go +++ b/services/postprocessing/pkg/command/server.go @@ -36,15 +36,9 @@ func Server(cfg *config.Config) *cli.Command { }, Action: func(c *cli.Context) error { var ( - gr = run.Group{} - logger = logging.Configure(cfg.Service.Name, cfg.Log) - - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + gr = run.Group{} + logger = logging.Configure(cfg.Service.Name, cfg.Log) + ctx, cancel = context.WithCancel(c.Context) ) defer cancel() diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index beb83ae506..2d02094a93 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -120,12 +120,7 @@ func Server(cfg *config.Config) *cli.Command { m := metrics.New() gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) defer cancel() diff --git a/services/search/pkg/command/server.go b/services/search/pkg/command/server.go index 4983ab9a83..1e823e42e4 100644 --- a/services/search/pkg/command/server.go +++ b/services/search/pkg/command/server.go @@ -41,12 +41,7 @@ func Server(cfg *config.Config) *cli.Command { return err } gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) defer cancel() mtrcs := metrics.New() diff --git a/services/settings/pkg/command/server.go b/services/settings/pkg/command/server.go index bcdb7f247d..73cbe437fe 100644 --- a/services/settings/pkg/command/server.go +++ b/services/settings/pkg/command/server.go @@ -44,12 +44,7 @@ func Server(cfg *config.Config) *cli.Command { } servers := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) defer cancel() mtrcs := metrics.New() diff --git a/services/sse/pkg/command/server.go b/services/sse/pkg/command/server.go index ac027d606d..06491d2906 100644 --- a/services/sse/pkg/command/server.go +++ b/services/sse/pkg/command/server.go @@ -37,13 +37,8 @@ func Server(cfg *config.Config) *cli.Command { Action: func(c *cli.Context) error { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - logger = log.NewLogger( + ctx, cancel = context.WithCancel(c.Context) + logger = log.NewLogger( log.Name(cfg.Service.Name), log.Level(cfg.Log.Level), log.Pretty(cfg.Log.Pretty), diff --git a/services/store/pkg/command/server.go b/services/store/pkg/command/server.go index 854bf0e7bb..9d32b3194c 100644 --- a/services/store/pkg/command/server.go +++ b/services/store/pkg/command/server.go @@ -35,9 +35,6 @@ func Server(cfg *config.Config) *cli.Command { if err != nil { return err } - if err != nil { - return err - } cfg.GrpcClient, err = ogrpc.NewClient( append(ogrpc.GetClientOptions(cfg.GRPCClientTLS), ogrpc.WithTraceProvider(traceProvider))..., ) @@ -47,13 +44,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - metrics = metrics.New() + ctx, cancel = context.WithCancel(c.Context) + metrics = metrics.New() ) defer cancel() diff --git a/services/thumbnails/pkg/command/server.go b/services/thumbnails/pkg/command/server.go index ba869dae9d..ea9288a55c 100644 --- a/services/thumbnails/pkg/command/server.go +++ b/services/thumbnails/pkg/command/server.go @@ -29,7 +29,7 @@ func Server(cfg *config.Config) *cli.Command { Before: func(_ *cli.Context) error { return configlog.ReturnFatal(parser.ParseConfig(cfg)) }, - Action: func(_ *cli.Context) error { + Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) @@ -43,13 +43,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - m = metrics.New() + ctx, cancel = context.WithCancel(c.Context) + m = metrics.New() ) defer cancel() diff --git a/services/userlog/pkg/command/server.go b/services/userlog/pkg/command/server.go index a0d2e99660..2535c38177 100644 --- a/services/userlog/pkg/command/server.go +++ b/services/userlog/pkg/command/server.go @@ -70,12 +70,7 @@ func Server(cfg *config.Config) *cli.Command { } gr := run.Group{} - ctx, cancel := func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() + ctx, cancel := context.WithCancel(c.Context) mtrcs := metrics.New() mtrcs.BuildInfo.WithLabelValues(version.GetString()).Set(1) diff --git a/services/web/pkg/command/server.go b/services/web/pkg/command/server.go index a4423d0fe3..2c3adfb214 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -27,7 +27,7 @@ func Server(cfg *config.Config) *cli.Command { Before: func(_ *cli.Context) error { return configlog.ReturnFatal(parser.ParseConfig(cfg)) }, - Action: func(_ *cli.Context) error { + Action: func(c *cli.Context) error { logger := logging.Configure(cfg.Service.Name, cfg.Log) traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) if err != nil { @@ -49,13 +49,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - m = metrics.New() + ctx, cancel = context.WithCancel(c.Context) + m = metrics.New() ) defer cancel() diff --git a/services/webdav/pkg/command/server.go b/services/webdav/pkg/command/server.go index 88983e1de7..34e2b0737f 100644 --- a/services/webdav/pkg/command/server.go +++ b/services/webdav/pkg/command/server.go @@ -44,13 +44,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - metrics = metrics.New() + ctx, cancel = context.WithCancel(c.Context) + metrics = metrics.New() ) defer cancel() diff --git a/services/webfinger/pkg/command/server.go b/services/webfinger/pkg/command/server.go index 2d8c4b8e45..b0e3453d7c 100644 --- a/services/webfinger/pkg/command/server.go +++ b/services/webfinger/pkg/command/server.go @@ -38,13 +38,8 @@ func Server(cfg *config.Config) *cli.Command { var ( gr = run.Group{} - ctx, cancel = func() (context.Context, context.CancelFunc) { - if cfg.Context == nil { - return context.WithCancel(context.Background()) - } - return context.WithCancel(cfg.Context) - }() - m = metrics.New(metrics.Logger(logger)) + ctx, cancel = context.WithCancel(c.Context) + m = metrics.New(metrics.Logger(logger)) ) defer cancel() From 7999e2969bd011afb2c6c37cd30be2d9c9554e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 24 Jul 2024 14:02:52 +0200 Subject: [PATCH 8/9] do not force exit to let all services shutdown gracefully MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/activitylog/pkg/command/server.go | 2 -- services/app-provider/pkg/command/server.go | 1 - services/app-registry/pkg/command/server.go | 1 - services/audit/pkg/command/server.go | 2 -- services/auth-app/pkg/command/server.go | 1 - services/auth-basic/pkg/command/server.go | 1 - services/auth-bearer/pkg/command/server.go | 1 - services/auth-machine/pkg/command/server.go | 1 - services/auth-service/pkg/command/server.go | 1 - services/clientlog/pkg/command/server.go | 2 -- services/frontend/pkg/command/server.go | 1 - services/graph/pkg/command/server.go | 2 -- services/groups/pkg/command/server.go | 1 - services/idm/pkg/command/server.go | 1 - services/idp/pkg/command/server.go | 1 - services/invitations/pkg/command/server.go | 2 -- services/nats/pkg/command/server.go | 2 -- services/ocdav/pkg/command/server.go | 2 -- services/ocm/pkg/command/server.go | 1 - services/ocs/pkg/command/server.go | 2 -- services/postprocessing/pkg/command/server.go | 1 - services/proxy/pkg/command/server.go | 2 -- services/settings/pkg/command/server.go | 3 --- services/sharing/pkg/command/server.go | 1 - services/storage-publiclink/pkg/command/server.go | 1 - services/storage-shares/pkg/command/server.go | 1 - services/storage-system/pkg/command/server.go | 1 - services/storage-users/pkg/command/server.go | 1 - services/store/pkg/command/server.go | 2 -- services/thumbnails/pkg/command/server.go | 2 -- services/userlog/pkg/command/server.go | 2 -- services/users/pkg/command/server.go | 1 - services/web/pkg/command/server.go | 1 - services/webdav/pkg/command/server.go | 2 -- services/webfinger/pkg/command/server.go | 2 -- 35 files changed, 51 deletions(-) diff --git a/services/activitylog/pkg/command/server.go b/services/activitylog/pkg/command/server.go index 4f9d7d1d4d..232bc1aa1f 100644 --- a/services/activitylog/pkg/command/server.go +++ b/services/activitylog/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/events/stream" @@ -140,7 +139,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index ff001ad9ad..450bb2d7ab 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index 61a27a3c0b..b8d1a790bf 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -60,7 +60,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/audit/pkg/command/server.go b/services/audit/pkg/command/server.go index aeaf01128f..93f945e497 100644 --- a/services/audit/pkg/command/server.go +++ b/services/audit/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/events/stream" @@ -55,7 +54,6 @@ func Server(cfg *config.Config) *cli.Command { Err(err). Msg("Shutting down server") cancel() - os.Exit(1) }) { diff --git a/services/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index 3ba0674a85..323e203c73 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index dd0f247e59..a89ccb5326 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -74,7 +74,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index d2e8863486..1c8e239b3a 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 070b00a6df..0a4dcbb59b 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index 05e0ca124d..58ab0dde1d 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/clientlog/pkg/command/server.go b/services/clientlog/pkg/command/server.go index b87ec8f231..80261be3d3 100644 --- a/services/clientlog/pkg/command/server.go +++ b/services/clientlog/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/events/stream" @@ -113,7 +112,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index 83c011be6d..cd22a4be7f 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -65,7 +65,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index 0cde2d4db4..7c10c330ba 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -64,7 +63,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index 3bdf022704..cd6dffcb6d 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -74,7 +74,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/idm/pkg/command/server.go b/services/idm/pkg/command/server.go index 16e8a081fe..3ec90806ac 100644 --- a/services/idm/pkg/command/server.go +++ b/services/idm/pkg/command/server.go @@ -90,7 +90,6 @@ func Server(cfg *config.Config) *cli.Command { Err(err). Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/idp/pkg/command/server.go b/services/idp/pkg/command/server.go index 78f658f146..02bf30eaa0 100644 --- a/services/idp/pkg/command/server.go +++ b/services/idp/pkg/command/server.go @@ -90,7 +90,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/invitations/pkg/command/server.go b/services/invitations/pkg/command/server.go index 183627c2d2..0b2b358cda 100644 --- a/services/invitations/pkg/command/server.go +++ b/services/invitations/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -84,7 +83,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index f7b00f2934..983909d8c6 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -4,7 +4,6 @@ import ( "context" "crypto/tls" "fmt" - "os" "github.com/oklog/run" @@ -109,7 +108,6 @@ func Server(cfg *config.Config) *cli.Command { natsServer.Shutdown() cancel() - os.Exit(1) }) return gr.Run() diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index e7573be410..4272419e84 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/cs3org/reva/v2/pkg/micro/ocdav" "github.com/cs3org/reva/v2/pkg/sharedconf" @@ -104,7 +103,6 @@ func Server(cfg *config.Config) *cli.Command { Str("server", c.Command.Name). Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index 6dd6f8f2fc..6dc234fda9 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -62,7 +62,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index 4a70945a8c..1054ea2e28 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -77,7 +76,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/postprocessing/pkg/command/server.go b/services/postprocessing/pkg/command/server.go index 5ccf65e6c1..6715a91463 100644 --- a/services/postprocessing/pkg/command/server.go +++ b/services/postprocessing/pkg/command/server.go @@ -82,7 +82,6 @@ func Server(cfg *config.Config) *cli.Command { Str("server", "http"). Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index 2d02094a93..7888a69794 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "fmt" "net/http" - "os" "time" gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" @@ -216,7 +215,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/settings/pkg/command/server.go b/services/settings/pkg/command/server.go index 73cbe437fe..5b11f00a56 100644 --- a/services/settings/pkg/command/server.go +++ b/services/settings/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -74,7 +73,6 @@ func Server(cfg *config.Config) *cli.Command { Str("server", "http"). Msg("shutting down server") cancel() - os.Exit(1) }) // prepare a gRPC server and add it to the group run. @@ -93,7 +91,6 @@ func Server(cfg *config.Config) *cli.Command { Str("server", "grpc"). Msg("shutting down server") cancel() - os.Exit(1) }) // prepare a debug server and add it to the group run. diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index d7e4ba47de..5fc2bf58c5 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -77,7 +77,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 3c3bacc701..64551f0366 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index 1e2a8745fb..4cc258a84a 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index f09e2f1f6a..369f2a5ad7 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index 444ce0a6dd..c4b4137910 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -63,7 +63,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/store/pkg/command/server.go b/services/store/pkg/command/server.go index 9d32b3194c..8971d75517 100644 --- a/services/store/pkg/command/server.go +++ b/services/store/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" @@ -68,7 +67,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/thumbnails/pkg/command/server.go b/services/thumbnails/pkg/command/server.go index ea9288a55c..f95cf99781 100644 --- a/services/thumbnails/pkg/command/server.go +++ b/services/thumbnails/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -69,7 +68,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) server, err := debug.Server( diff --git a/services/userlog/pkg/command/server.go b/services/userlog/pkg/command/server.go index 2535c38177..71a52ca7fa 100644 --- a/services/userlog/pkg/command/server.go +++ b/services/userlog/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/cs3org/reva/v2/pkg/events" "github.com/cs3org/reva/v2/pkg/events/stream" @@ -141,7 +140,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index 2b96aac547..92094a627a 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -74,7 +74,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) debugServer, err := debug.Server( diff --git a/services/web/pkg/command/server.go b/services/web/pkg/command/server.go index 2c3adfb214..5ba9134319 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -89,7 +89,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/webdav/pkg/command/server.go b/services/webdav/pkg/command/server.go index 34e2b0737f..d7ed386242 100644 --- a/services/webdav/pkg/command/server.go +++ b/services/webdav/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -79,7 +78,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } diff --git a/services/webfinger/pkg/command/server.go b/services/webfinger/pkg/command/server.go index b0e3453d7c..0ba9cbe129 100644 --- a/services/webfinger/pkg/command/server.go +++ b/services/webfinger/pkg/command/server.go @@ -3,7 +3,6 @@ package command import ( "context" "fmt" - "os" "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" @@ -92,7 +91,6 @@ func Server(cfg *config.Config) *cli.Command { Msg("Shutting down server") cancel() - os.Exit(1) }) } From 066c4b8173b7275ae5793a5d6de9ce29e3469a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 29 Jul 2024 16:28:13 +0200 Subject: [PATCH 9/9] only register signal handling once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- ocis/pkg/command/root.go | 2 +- ocis/pkg/runtime/service/service.go | 18 +++++++----------- services/activitylog/cmd/activitylog/main.go | 2 +- services/antivirus/cmd/antivirus/main.go | 2 +- services/app-provider/cmd/app-provider/main.go | 2 +- services/app-registry/cmd/app-registry/main.go | 2 +- services/audit/cmd/audit/main.go | 2 +- services/auth-app/cmd/auth-app/main.go | 2 +- services/auth-basic/cmd/auth-basic/main.go | 2 +- services/auth-bearer/cmd/auth-bearer/main.go | 2 +- services/auth-machine/cmd/auth-machine/main.go | 2 +- services/auth-service/cmd/auth-service/main.go | 2 +- services/clientlog/cmd/clientlog/main.go | 2 +- services/eventhistory/cmd/eventhistory/main.go | 2 +- services/frontend/cmd/frontend/main.go | 2 +- services/gateway/cmd/gateway/main.go | 2 +- services/graph/cmd/graph/main.go | 2 +- services/groups/cmd/groups/main.go | 2 +- services/idm/cmd/idm/main.go | 2 +- services/idp/cmd/idp/main.go | 2 +- services/invitations/cmd/invitations/main.go | 2 +- services/nats/cmd/nats/main.go | 2 +- .../notifications/cmd/notifications/main.go | 2 +- services/ocdav/cmd/ocdav/main.go | 2 +- services/ocm/cmd/ocm/main.go | 2 +- services/ocs/cmd/ocs/main.go | 2 +- services/policies/cmd/policies/main.go | 2 +- .../postprocessing/cmd/postprocessing/main.go | 2 +- services/proxy/cmd/proxy/main.go | 2 +- services/search/cmd/search/main.go | 2 +- services/settings/cmd/settings/main.go | 2 +- services/sharing/cmd/sharing/main.go | 2 +- services/sse/cmd/sse/main.go | 2 +- .../cmd/storage-publiclink/main.go | 2 +- .../storage-shares/cmd/storage-shares/main.go | 2 +- .../storage-system/cmd/storage-system/main.go | 2 +- .../storage-users/cmd/storage-users/main.go | 2 +- services/store/cmd/store/main.go | 2 +- services/thumbnails/cmd/thumbnails/main.go | 2 +- services/userlog/cmd/userlog/main.go | 2 +- services/users/cmd/user/main.go | 2 +- services/web/cmd/web/main.go | 2 +- services/webdav/cmd/webdav/main.go | 2 +- services/webfinger/cmd/webfinger/main.go | 2 +- 44 files changed, 50 insertions(+), 54 deletions(-) diff --git a/ocis/pkg/command/root.go b/ocis/pkg/command/root.go index 666ee0544f..6dd7136e41 100644 --- a/ocis/pkg/command/root.go +++ b/ocis/pkg/command/root.go @@ -28,6 +28,6 @@ func Execute() error { ) } - ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) return app.RunContext(ctx, os.Args) } diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index eac779809d..311d6f7c1e 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -7,10 +7,8 @@ import ( "net/http" "net/rpc" "os" - "os/signal" "sort" "strings" - "syscall" "time" authapp "github.com/owncloud/ocis/v2/services/auth-app/pkg/command" @@ -362,9 +360,8 @@ func Start(ctx context.Context, o ...Option) error { return err } - // halt listens for interrupt signals and blocks. - halt := make(chan os.Signal, 1) - signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) + // get a cancel function to stop the service + ctx, cancel := context.WithCancel(ctx) // tolerance controls backoff cycles from the supervisor. tolerance := 5 @@ -376,7 +373,7 @@ func Start(ctx context.Context, o ...Option) error { if e.Type() == suture.EventTypeBackoff { totalBackoff++ if totalBackoff == tolerance { - halt <- os.Interrupt + cancel() } } s.Log.Info().Str("event", e.String()).Msg(fmt.Sprintf("supervisor: %v", e.Map()["supervisor_name"])) @@ -424,8 +421,8 @@ func Start(ctx context.Context, o ...Option) error { // https://pkg.go.dev/github.com/thejerf/suture/v4@v4.0.0#Supervisor go s.Supervisor.ServeBackground(s.context) - // trap will block on halt channel for interruptions. - go trap(s, halt) + // trap will block on context done channel for interruptions. + go trap(s, ctx) for i, service := range s.Services { scheduleServiceTokens(s, service) @@ -508,9 +505,8 @@ func (s *Service) List(_ struct{}, reply *string) error { // trap blocks on halt channel. When the runtime is interrupted it // signals the controller to stop any supervised process. -func trap(s *Service, halt chan os.Signal) { - <-halt - s.cancel() +func trap(s *Service, ctx context.Context) { + <-ctx.Done() for sName := range s.serviceToken { for i := range s.serviceToken[sName] { if err := s.Supervisor.Remove(s.serviceToken[sName][i]); err != nil { diff --git a/services/activitylog/cmd/activitylog/main.go b/services/activitylog/cmd/activitylog/main.go index a8555bd20d..dae55b4f16 100644 --- a/services/activitylog/cmd/activitylog/main.go +++ b/services/activitylog/cmd/activitylog/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/antivirus/cmd/antivirus/main.go b/services/antivirus/cmd/antivirus/main.go index 174e6fe3fb..8f0332ad1d 100644 --- a/services/antivirus/cmd/antivirus/main.go +++ b/services/antivirus/cmd/antivirus/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/app-provider/cmd/app-provider/main.go b/services/app-provider/cmd/app-provider/main.go index 42b66fd9c0..1d7474d45b 100644 --- a/services/app-provider/cmd/app-provider/main.go +++ b/services/app-provider/cmd/app-provider/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/app-registry/cmd/app-registry/main.go b/services/app-registry/cmd/app-registry/main.go index e00af3f2ab..ddb4faa295 100644 --- a/services/app-registry/cmd/app-registry/main.go +++ b/services/app-registry/cmd/app-registry/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/audit/cmd/audit/main.go b/services/audit/cmd/audit/main.go index 8b33880d6c..56413c60b5 100644 --- a/services/audit/cmd/audit/main.go +++ b/services/audit/cmd/audit/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/auth-app/cmd/auth-app/main.go b/services/auth-app/cmd/auth-app/main.go index d6cdb39e0c..ada20d1afd 100644 --- a/services/auth-app/cmd/auth-app/main.go +++ b/services/auth-app/cmd/auth-app/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/auth-basic/cmd/auth-basic/main.go b/services/auth-basic/cmd/auth-basic/main.go index 784d715be5..6235d5da74 100644 --- a/services/auth-basic/cmd/auth-basic/main.go +++ b/services/auth-basic/cmd/auth-basic/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/auth-bearer/cmd/auth-bearer/main.go b/services/auth-bearer/cmd/auth-bearer/main.go index 4bc12ab09c..8cab6c04a1 100644 --- a/services/auth-bearer/cmd/auth-bearer/main.go +++ b/services/auth-bearer/cmd/auth-bearer/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/auth-machine/cmd/auth-machine/main.go b/services/auth-machine/cmd/auth-machine/main.go index aeb79d5ccf..f2b0bdc360 100644 --- a/services/auth-machine/cmd/auth-machine/main.go +++ b/services/auth-machine/cmd/auth-machine/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/auth-service/cmd/auth-service/main.go b/services/auth-service/cmd/auth-service/main.go index 81ce1579e9..70b2c3d7f9 100644 --- a/services/auth-service/cmd/auth-service/main.go +++ b/services/auth-service/cmd/auth-service/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/clientlog/cmd/clientlog/main.go b/services/clientlog/cmd/clientlog/main.go index cdd91f273a..9c6595c600 100644 --- a/services/clientlog/cmd/clientlog/main.go +++ b/services/clientlog/cmd/clientlog/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/eventhistory/cmd/eventhistory/main.go b/services/eventhistory/cmd/eventhistory/main.go index 4a1d3f8701..47eb6483c1 100644 --- a/services/eventhistory/cmd/eventhistory/main.go +++ b/services/eventhistory/cmd/eventhistory/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/frontend/cmd/frontend/main.go b/services/frontend/cmd/frontend/main.go index 8e12e7761a..a3e887680f 100644 --- a/services/frontend/cmd/frontend/main.go +++ b/services/frontend/cmd/frontend/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/gateway/cmd/gateway/main.go b/services/gateway/cmd/gateway/main.go index 503e12de1c..766b15bcf9 100644 --- a/services/gateway/cmd/gateway/main.go +++ b/services/gateway/cmd/gateway/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/graph/cmd/graph/main.go b/services/graph/cmd/graph/main.go index 0775fcb487..b0d9189e0a 100644 --- a/services/graph/cmd/graph/main.go +++ b/services/graph/cmd/graph/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/groups/cmd/groups/main.go b/services/groups/cmd/groups/main.go index d13447d496..c1d4afadbe 100644 --- a/services/groups/cmd/groups/main.go +++ b/services/groups/cmd/groups/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/idm/cmd/idm/main.go b/services/idm/cmd/idm/main.go index ab6af89f2b..e61c15349d 100644 --- a/services/idm/cmd/idm/main.go +++ b/services/idm/cmd/idm/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/idp/cmd/idp/main.go b/services/idp/cmd/idp/main.go index d3def5ab1c..de20d3a5b3 100644 --- a/services/idp/cmd/idp/main.go +++ b/services/idp/cmd/idp/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/invitations/cmd/invitations/main.go b/services/invitations/cmd/invitations/main.go index 86da31fcb1..8c9a45aeab 100644 --- a/services/invitations/cmd/invitations/main.go +++ b/services/invitations/cmd/invitations/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/nats/cmd/nats/main.go b/services/nats/cmd/nats/main.go index 2e75edad3d..347a2cc3e9 100644 --- a/services/nats/cmd/nats/main.go +++ b/services/nats/cmd/nats/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/notifications/cmd/notifications/main.go b/services/notifications/cmd/notifications/main.go index 1836a24f85..73f31b88fc 100644 --- a/services/notifications/cmd/notifications/main.go +++ b/services/notifications/cmd/notifications/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/ocdav/cmd/ocdav/main.go b/services/ocdav/cmd/ocdav/main.go index 964af1667c..5a6d24390f 100644 --- a/services/ocdav/cmd/ocdav/main.go +++ b/services/ocdav/cmd/ocdav/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/ocm/cmd/ocm/main.go b/services/ocm/cmd/ocm/main.go index 6a4b7926d8..77a2913ba6 100644 --- a/services/ocm/cmd/ocm/main.go +++ b/services/ocm/cmd/ocm/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/ocs/cmd/ocs/main.go b/services/ocs/cmd/ocs/main.go index 8ae7d02622..96de1a08e1 100644 --- a/services/ocs/cmd/ocs/main.go +++ b/services/ocs/cmd/ocs/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/policies/cmd/policies/main.go b/services/policies/cmd/policies/main.go index 09abb5e85e..e774e8c4a6 100644 --- a/services/policies/cmd/policies/main.go +++ b/services/policies/cmd/policies/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/postprocessing/cmd/postprocessing/main.go b/services/postprocessing/cmd/postprocessing/main.go index e42d50ccdf..869d23db02 100644 --- a/services/postprocessing/cmd/postprocessing/main.go +++ b/services/postprocessing/cmd/postprocessing/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/proxy/cmd/proxy/main.go b/services/proxy/cmd/proxy/main.go index 9c51a443e4..889bc6772e 100644 --- a/services/proxy/cmd/proxy/main.go +++ b/services/proxy/cmd/proxy/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/search/cmd/search/main.go b/services/search/cmd/search/main.go index 807b664273..1426e298d3 100644 --- a/services/search/cmd/search/main.go +++ b/services/search/cmd/search/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/settings/cmd/settings/main.go b/services/settings/cmd/settings/main.go index 8833af4bbe..965c638540 100644 --- a/services/settings/cmd/settings/main.go +++ b/services/settings/cmd/settings/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/sharing/cmd/sharing/main.go b/services/sharing/cmd/sharing/main.go index cb5b4e5cca..c059753eb0 100644 --- a/services/sharing/cmd/sharing/main.go +++ b/services/sharing/cmd/sharing/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/sse/cmd/sse/main.go b/services/sse/cmd/sse/main.go index 9b31eea528..4e951b9251 100644 --- a/services/sse/cmd/sse/main.go +++ b/services/sse/cmd/sse/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/storage-publiclink/cmd/storage-publiclink/main.go b/services/storage-publiclink/cmd/storage-publiclink/main.go index e1637605c6..2207a7829e 100644 --- a/services/storage-publiclink/cmd/storage-publiclink/main.go +++ b/services/storage-publiclink/cmd/storage-publiclink/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/storage-shares/cmd/storage-shares/main.go b/services/storage-shares/cmd/storage-shares/main.go index 472cf04c8f..5a292e0ec2 100644 --- a/services/storage-shares/cmd/storage-shares/main.go +++ b/services/storage-shares/cmd/storage-shares/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/storage-system/cmd/storage-system/main.go b/services/storage-system/cmd/storage-system/main.go index 761e1ab233..9f2bdaa45e 100644 --- a/services/storage-system/cmd/storage-system/main.go +++ b/services/storage-system/cmd/storage-system/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/storage-users/cmd/storage-users/main.go b/services/storage-users/cmd/storage-users/main.go index 142e5a4413..62bf86fd00 100644 --- a/services/storage-users/cmd/storage-users/main.go +++ b/services/storage-users/cmd/storage-users/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/store/cmd/store/main.go b/services/store/cmd/store/main.go index 3bbf8cff80..4384dfab8c 100644 --- a/services/store/cmd/store/main.go +++ b/services/store/cmd/store/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/thumbnails/cmd/thumbnails/main.go b/services/thumbnails/cmd/thumbnails/main.go index 9f3cce9566..f2e8ce6267 100644 --- a/services/thumbnails/cmd/thumbnails/main.go +++ b/services/thumbnails/cmd/thumbnails/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/userlog/cmd/userlog/main.go b/services/userlog/cmd/userlog/main.go index 2df9a2a98f..58d53b0636 100644 --- a/services/userlog/cmd/userlog/main.go +++ b/services/userlog/cmd/userlog/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/users/cmd/user/main.go b/services/users/cmd/user/main.go index 6d69289324..35d221577c 100644 --- a/services/users/cmd/user/main.go +++ b/services/users/cmd/user/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/web/cmd/web/main.go b/services/web/cmd/web/main.go index 2ee45f9eeb..2331767f35 100644 --- a/services/web/cmd/web/main.go +++ b/services/web/cmd/web/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/webdav/cmd/webdav/main.go b/services/webdav/cmd/webdav/main.go index 08d0bdbbe4..444ea77ff8 100644 --- a/services/webdav/cmd/webdav/main.go +++ b/services/webdav/cmd/webdav/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) } diff --git a/services/webfinger/cmd/webfinger/main.go b/services/webfinger/cmd/webfinger/main.go index b67f9ba63e..112094e8a4 100644 --- a/services/webfinger/cmd/webfinger/main.go +++ b/services/webfinger/cmd/webfinger/main.go @@ -12,7 +12,7 @@ import ( func main() { cfg := defaults.DefaultConfig() - cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) if err := command.Execute(cfg); err != nil { os.Exit(1) }