From ad43ae824c15ad333892c1020d6479a3ec35d1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 25 Oct 2024 01:01:03 +0200 Subject: [PATCH 1/4] delete unused trap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- ocis-pkg/sync/trap.go | 21 ------------------- services/app-provider/pkg/command/server.go | 5 ----- services/app-provider/pkg/config/config.go | 3 +-- services/app-registry/pkg/config/config.go | 3 +-- services/auth-app/pkg/command/server.go | 5 ----- services/auth-app/pkg/config/config.go | 3 +-- services/auth-basic/pkg/command/server.go | 5 ----- services/auth-basic/pkg/config/config.go | 3 +-- services/auth-bearer/pkg/command/server.go | 5 ----- services/auth-bearer/pkg/config/config.go | 3 +-- services/auth-machine/pkg/command/server.go | 5 ----- services/auth-machine/pkg/config/config.go | 3 +-- services/auth-service/pkg/command/server.go | 5 ----- services/auth-service/pkg/config/config.go | 3 +-- services/frontend/pkg/command/server.go | 5 ----- services/frontend/pkg/config/config.go | 3 +-- services/gateway/pkg/config/config.go | 3 +-- services/groups/pkg/command/server.go | 5 ----- services/groups/pkg/config/config.go | 3 +-- services/ocm/pkg/command/server.go | 5 ----- services/ocm/pkg/config/config.go | 3 +-- services/sharing/pkg/command/server.go | 5 ----- services/sharing/pkg/config/config.go | 5 ++--- .../storage-publiclink/pkg/command/server.go | 5 ----- .../storage-publiclink/pkg/config/config.go | 3 +-- services/storage-shares/pkg/command/server.go | 5 ----- services/storage-shares/pkg/config/config.go | 3 +-- services/storage-system/pkg/command/server.go | 5 ----- services/storage-system/pkg/config/config.go | 3 +-- services/storage-users/pkg/command/server.go | 5 ----- services/storage-users/pkg/config/config.go | 3 +-- services/users/pkg/command/server.go | 5 ----- services/users/pkg/config/config.go | 3 +-- 33 files changed, 18 insertions(+), 131 deletions(-) delete mode 100644 ocis-pkg/sync/trap.go diff --git a/ocis-pkg/sync/trap.go b/ocis-pkg/sync/trap.go deleted file mode 100644 index 13eb08a4725..00000000000 --- a/ocis-pkg/sync/trap.go +++ /dev/null @@ -1,21 +0,0 @@ -package sync - -import ( - "context" - "os" - "os/signal" - - "github.com/oklog/run" -) - -// Trap listens to interrupt signals and handles context cancellation and channel closing on a group run. -func Trap(gr *run.Group, cancel context.CancelFunc) { - stop := make(chan os.Signal, 1) - gr.Add(func() error { - signal.Notify(stop, os.Interrupt) - <-stop - return nil - }, func(err error) { - cancel() - }) -} diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 6d0a044ae6f..28a7f89b77a 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/app-provider/pkg/config" @@ -77,10 +76,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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-provider/pkg/config/config.go b/services/app-provider/pkg/config/config.go index 2bce3829672..1c422ab21d7 100644 --- a/services/app-provider/pkg/config/config.go +++ b/services/app-provider/pkg/config/config.go @@ -22,8 +22,7 @@ type Config struct { Driver string `yaml:"driver" env:"APP_PROVIDER_DRIVER" desc:"Driver, the APP PROVIDER services uses. Only 'wopi' is supported as of now." introductionVersion:"pre5.0"` Drivers Drivers `yaml:"drivers"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/app-registry/pkg/config/config.go b/services/app-registry/pkg/config/config.go index 4a385e09dc0..15c212539b0 100644 --- a/services/app-registry/pkg/config/config.go +++ b/services/app-registry/pkg/config/config.go @@ -21,8 +21,7 @@ type Config struct { AppRegistry AppRegistry `yaml:"app_registry"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index 00b75288776..10ba77b1ca6 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -13,7 +13,6 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" ogrpc "github.com/owncloud/ocis/v2/ocis-pkg/service/grpc" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" settingssvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/settings/v0" @@ -86,10 +85,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/auth-app/pkg/config/config.go index 2171c21a118..ef7cc1ebe8c 100644 --- a/services/auth-app/pkg/config/config.go +++ b/services/auth-app/pkg/config/config.go @@ -28,8 +28,7 @@ type Config struct { AllowImpersonation bool `yaml:"allow_impersonation" env:"AUTH_APP_ENABLE_IMPERSONATION" desc:"Allows admins to create app tokens for other users. Used for migration. Do NOT use in productive deployments." introductionVersion:"7.0.0"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } // Log defines the loging configuration diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index 475f5333bf0..a6d7d95ecb2 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -12,7 +12,6 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/ldap" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config" @@ -91,10 +90,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/auth-basic/pkg/config/config.go index 5c1558679fb..65aa3bc222b 100644 --- a/services/auth-basic/pkg/config/config.go +++ b/services/auth-basic/pkg/config/config.go @@ -22,8 +22,7 @@ type Config struct { AuthProvider string `yaml:"auth_provider" env:"AUTH_BASIC_AUTH_MANAGER" desc:"The authentication manager to check if credentials are valid. Supported value is 'ldap'." introductionVersion:"pre5.0"` AuthProviders AuthProviders `yaml:"auth_providers"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index 76877780e9f..e6d93f7a2c1 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config" @@ -78,10 +77,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/auth-bearer/pkg/config/config.go index 57a2db3f90a..c09ddbaae7d 100644 --- a/services/auth-bearer/pkg/config/config.go +++ b/services/auth-bearer/pkg/config/config.go @@ -22,8 +22,7 @@ type Config struct { OIDC OIDC `yaml:"oidc"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 06a315d1dea..d5d996c9af3 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config" @@ -78,10 +77,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/auth-machine/pkg/config/config.go index b92a860b58c..4c1c01b0c8e 100644 --- a/services/auth-machine/pkg/config/config.go +++ b/services/auth-machine/pkg/config/config.go @@ -22,8 +22,7 @@ type Config struct { MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;AUTH_MACHINE_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services." introductionVersion:"pre5.0"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index 35816e7806b..e01773cca69 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/auth-service/pkg/config" @@ -79,10 +78,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/auth-service/pkg/config/config.go index 4c62426242b..d3be2fe265f 100644 --- a/services/auth-service/pkg/config/config.go +++ b/services/auth-service/pkg/config/config.go @@ -21,8 +21,7 @@ type Config struct { // TODO: when using multiple service accounts we need to find a way to configure them ServiceAccount ServiceAccount `yaml:"service_account"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index 8f936935f34..ece62410141 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/frontend/pkg/config" @@ -82,10 +81,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - 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/frontend/pkg/config/config.go b/services/frontend/pkg/config/config.go index 626d85a57f7..d4e2b51d5a3 100644 --- a/services/frontend/pkg/config/config.go +++ b/services/frontend/pkg/config/config.go @@ -58,8 +58,7 @@ type Config struct { PasswordPolicy PasswordPolicy `yaml:"password_policy"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/gateway/pkg/config/config.go b/services/gateway/pkg/config/config.go index 081e0542120..53699fccce0 100644 --- a/services/gateway/pkg/config/config.go +++ b/services/gateway/pkg/config/config.go @@ -48,8 +48,7 @@ type Config struct { StorageRegistry StorageRegistry `yaml:"storage_registry"` // TODO: should we even support switching this? - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index f79bc953e13..36c83a03b2e 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -12,7 +12,6 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/ldap" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/groups/pkg/config" @@ -91,10 +90,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/groups/pkg/config/config.go b/services/groups/pkg/config/config.go index fa6804aa768..2219fbab2b3 100644 --- a/services/groups/pkg/config/config.go +++ b/services/groups/pkg/config/config.go @@ -23,8 +23,7 @@ type Config struct { Driver string `yaml:"driver" env:"GROUPS_DRIVER" desc:"The driver which should be used by the groups service. Supported values are 'ldap' and 'owncloudsql'." introductionVersion:"pre5.0"` Drivers Drivers `yaml:"drivers"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index 7e7265b066d..64fced6883d 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/ocm/pkg/config" @@ -79,10 +78,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/ocm/pkg/config/config.go b/services/ocm/pkg/config/config.go index db50077e96a..75c292d9126 100644 --- a/services/ocm/pkg/config/config.go +++ b/services/ocm/pkg/config/config.go @@ -38,8 +38,7 @@ type Config struct { OCMCore OCMCore `yaml:"ocm_core"` OCMStorageProvider OCMStorageProvider `yaml:"ocm_storage_provider"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } // HTTPConfig defines the available http configuration. diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index 73292fd3c29..94d91a91c75 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -12,7 +12,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/sharing/pkg/config" @@ -94,10 +93,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/sharing/pkg/config/config.go b/services/sharing/pkg/config/config.go index cbb05888ca1..89501e7a39e 100644 --- a/services/sharing/pkg/config/config.go +++ b/services/sharing/pkg/config/config.go @@ -28,10 +28,9 @@ type Config struct { WriteableShareMustHavePassword bool `yaml:"public_sharing_writeableshare_must_have_password" env:"OCIS_SHARING_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD;SHARING_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD" desc:"Set this to true if you want to enforce passwords on Uploader, Editor or Contributor shares. If not using the global OCIS_SHARING_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD, you must define the FRONTEND_OCS_PUBLIC_WRITEABLE_SHARE_MUST_HAVE_PASSWORD in the frontend service." introductionVersion:"5.0"` PublicShareMustHavePassword bool `yaml:"public_sharing_share_must_have_password" env:"OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD;SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD" desc:"Set this to true if you want to enforce passwords on all public shares." introductionVersion:"5.0"` EnableExpiredSharesCleanup bool `yaml:"enable_expired_shares_cleanup"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + PasswordPolicy PasswordPolicy `yaml:"password_policy"` - PasswordPolicy PasswordPolicy `yaml:"password_policy"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index d15dac8ceca..9a0c399160d 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config" @@ -78,10 +77,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/storage-publiclink/pkg/config/config.go index ba35b21238e..c6cab3d609e 100644 --- a/services/storage-publiclink/pkg/config/config.go +++ b/services/storage-publiclink/pkg/config/config.go @@ -22,8 +22,7 @@ type Config struct { StorageProvider StorageProvider `yaml:"storage_provider"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index 41757ff57d9..7ed4bec2587 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config" @@ -78,10 +77,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/storage-shares/pkg/config/config.go index a166646007e..b6f7b8e8da1 100644 --- a/services/storage-shares/pkg/config/config.go +++ b/services/storage-shares/pkg/config/config.go @@ -24,8 +24,7 @@ type Config struct { ReadOnly bool `yaml:"readonly" env:"STORAGE_SHARES_READ_ONLY" desc:"Set this storage to be read-only." introductionVersion:"pre5.0"` SharesProviderEndpoint string `yaml:"user_share_provider_endpoint" env:"STORAGE_SHARES_USER_SHARE_PROVIDER_ENDPOINT" desc:"GRPC endpoint of the SHARING service." introductionVersion:"pre5.0"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { Level string `yaml:"level" env:"OCIS_LOG_LEVEL;STORAGE_SHARES_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"pre5.0"` diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index 2b50a59a0e9..2c2e058cb6d 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -11,7 +11,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config" @@ -78,10 +77,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/storage-system/pkg/config/config.go index 5b3679751b4..e215ba6e610 100644 --- a/services/storage-system/pkg/config/config.go +++ b/services/storage-system/pkg/config/config.go @@ -31,8 +31,7 @@ type Config struct { Drivers Drivers `yaml:"drivers"` DataServerURL string `yaml:"data_server_url" env:"STORAGE_SYSTEM_DATA_SERVER_URL" desc:"URL of the data server, needs to be reachable by other services using this service." introductionVersion:"pre5.0"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } // Log holds Log config diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index f88ed590c9b..db64d57a373 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -12,7 +12,6 @@ import ( "github.com/oklog/run" "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config" @@ -80,10 +79,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/config/config.go b/services/storage-users/pkg/config/config.go index 690e948068a..6a65fd1c30d 100644 --- a/services/storage-users/pkg/config/config.go +++ b/services/storage-users/pkg/config/config.go @@ -45,8 +45,7 @@ type Config struct { MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;STORAGE_USERS_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services." introductionVersion:"5.0"` CliMaxAttemptsRenameFile int `yaml:"max_attempts_rename_file" env:"STORAGE_USERS_CLI_MAX_ATTEMPTS_RENAME_FILE" desc:"The maximum number of attempts to rename a file when a user restores a file to an existing destination with the same name. The minimum value is 100." introductionVersion:"5.0"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } // Log configures the logging diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index aed4caa147c..115b58af3cd 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -12,7 +12,6 @@ import ( "github.com/owncloud/ocis/v2/ocis-pkg/config/configlog" "github.com/owncloud/ocis/v2/ocis-pkg/ldap" "github.com/owncloud/ocis/v2/ocis-pkg/registry" - "github.com/owncloud/ocis/v2/ocis-pkg/sync" "github.com/owncloud/ocis/v2/ocis-pkg/tracing" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/users/pkg/config" @@ -91,10 +90,6 @@ func Server(cfg *config.Config) *cli.Command { cancel() }) - if !cfg.Supervised { - sync.Trap(&gr, cancel) - } - grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Protocol, 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/users/pkg/config/config.go b/services/users/pkg/config/config.go index e6c7ddfdfd1..6383ac1b9c6 100644 --- a/services/users/pkg/config/config.go +++ b/services/users/pkg/config/config.go @@ -23,8 +23,7 @@ type Config struct { Driver string `yaml:"driver" env:"USERS_DRIVER" desc:"The driver which should be used by the users service. Supported values are 'ldap' and 'owncloudsql'." introductionVersion:"pre5.0"` Drivers Drivers `yaml:"drivers"` - Supervised bool `yaml:"-"` - Context context.Context `yaml:"-"` + Context context.Context `yaml:"-"` } type Log struct { Level string `yaml:"level" env:"OCIS_LOG_LEVEL;USERS_LOG_LEVEL" desc:"The log level. Valid values are: 'panic', 'fatal', 'error', 'warn', 'info', 'debug', 'trace'." introductionVersion:"pre5.0"` From dde999d5c27603673e6ab92e05da4349bf96e68a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 25 Oct 2024 01:07:04 +0200 Subject: [PATCH 2/4] align shutdown logging 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 | 15 ++++++--- services/app-provider/pkg/command/server.go | 15 ++++++--- services/app-registry/pkg/command/server.go | 15 ++++++--- services/audit/pkg/command/server.go | 15 +++++++-- services/auth-app/pkg/command/server.go | 15 ++++++--- services/auth-basic/pkg/command/server.go | 15 ++++++--- services/auth-bearer/pkg/command/server.go | 15 ++++++--- services/auth-machine/pkg/command/server.go | 15 ++++++--- services/auth-service/pkg/command/server.go | 15 ++++++--- services/clientlog/pkg/command/server.go | 15 ++++++--- services/collaboration/pkg/command/server.go | 13 +++++++- services/eventhistory/pkg/command/server.go | 15 ++++++--- services/frontend/pkg/command/server.go | 15 ++++++--- services/gateway/pkg/command/server.go | 15 ++++++--- services/graph/pkg/command/server.go | 15 ++++++--- services/groups/pkg/command/server.go | 15 ++++++--- services/idm/pkg/command/server.go | 15 +++++++-- services/idp/pkg/command/server.go | 15 ++++++--- services/invitations/pkg/command/server.go | 15 ++++++--- services/nats/pkg/command/server.go | 14 ++++++-- services/ocdav/pkg/command/server.go | 16 +++++++--- services/ocm/pkg/command/server.go | 15 ++++++--- services/ocs/pkg/command/server.go | 15 ++++++--- services/postprocessing/pkg/command/server.go | 16 +++++++--- services/proxy/pkg/command/server.go | 15 ++++++--- services/search/pkg/command/server.go | 16 +++++++--- services/settings/pkg/command/server.go | 32 ++++++++++++++----- services/sharing/pkg/command/server.go | 15 ++++++--- .../storage-publiclink/pkg/command/server.go | 15 ++++++--- services/storage-shares/pkg/command/server.go | 15 ++++++--- services/storage-system/pkg/command/server.go | 15 ++++++--- services/storage-users/pkg/command/server.go | 32 +++++++++++++------ services/thumbnails/pkg/command/server.go | 31 +++++++++++++----- services/userlog/pkg/command/server.go | 15 ++++++--- services/users/pkg/command/server.go | 15 ++++++--- services/web/pkg/command/server.go | 15 ++++++--- services/webdav/pkg/command/server.go | 15 ++++++--- services/webfinger/pkg/command/server.go | 15 ++++++--- 38 files changed, 461 insertions(+), 159 deletions(-) diff --git a/services/activitylog/pkg/command/server.go b/services/activitylog/pkg/command/server.go index 67fa7ad9c6b..9490e588f95 100644 --- a/services/activitylog/pkg/command/server.go +++ b/services/activitylog/pkg/command/server.go @@ -134,10 +134,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return svc.Run() }, func(err error) { - logger.Error(). - Str("transport", "http"). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 28a7f89b77a..4711b016023 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Str("server", cfg.Service.Name). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index b37f29a7689..14f4ab277fc 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Str("server", cfg.Service.Name). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/audit/pkg/command/server.go b/services/audit/pkg/command/server.go index 84bf206bc9d..61503c7fb18 100644 --- a/services/audit/pkg/command/server.go +++ b/services/audit/pkg/command/server.go @@ -49,9 +49,18 @@ func Server(cfg *config.Config) *cli.Command { svc.AuditLoggerFromConfig(ctx, cfg.Auditlog, evts, logger) return nil }, func(err error) { - logger.Error(). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) diff --git a/services/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index 10ba77b1ca6..96ead3230cf 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -62,10 +62,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Str("server", cfg.Service.Name). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index a6d7d95ecb2..37204df408e 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -67,10 +67,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Str("server", cfg.Service.Name). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index e6d93f7a2c1..8056387f96b 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Str("server", cfg.Service.Name). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index d5d996c9af3..84d039a20ae 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", cfg.Service.Name). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index e01773cca69..887cdd1cb43 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { ) return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", cfg.Service.Name). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/clientlog/pkg/command/server.go b/services/clientlog/pkg/command/server.go index b2194f792b2..9a7a05cf311 100644 --- a/services/clientlog/pkg/command/server.go +++ b/services/clientlog/pkg/command/server.go @@ -106,10 +106,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return svc.Run() }, func(err error) { - logger.Error(). - Str("transport", "http"). - Err(err). - Msg("Shutting down server") + if err != nil { + logger.Info(). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/collaboration/pkg/command/server.go b/services/collaboration/pkg/command/server.go index fbfcc88f91b..51c788bc237 100644 --- a/services/collaboration/pkg/command/server.go +++ b/services/collaboration/pkg/command/server.go @@ -103,7 +103,18 @@ func Server(cfg *config.Config) *cli.Command { return grpcServer.Serve(l) }, func(err error) { - logger.Error().Err(err).Str("server", "grpc").Msg("shutting down server") + if err != nil { + logger.Info(). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) diff --git a/services/eventhistory/pkg/command/server.go b/services/eventhistory/pkg/command/server.go index 15e0dfd932b..1fc33fdb3a0 100644 --- a/services/eventhistory/pkg/command/server.go +++ b/services/eventhistory/pkg/command/server.go @@ -83,10 +83,17 @@ func Server(cfg *config.Config) *cli.Command { ) gr.Add(service.Run, func(err error) { - logger.Error(). - Err(err). - Str("server", "grpc"). - Msg("Shutting Down server") + if err == nil { + logger.Info(). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index ece62410141..e9597d7042e 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -58,10 +58,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", cfg.Service.Name). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index bafbf7cd828..905db3bb3bc 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/pkg/command/server.go @@ -56,10 +56,17 @@ func Server(cfg *config.Config) *cli.Command { Msg("reva runtime exited") return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", cfg.Service.Name). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index 7c10c330ba1..c8820d4efde 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -57,10 +57,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Str("transport", "http"). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index 36c83a03b2e..b5d6030d2eb 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -67,10 +67,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Str("server", cfg.Service.Name). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/idm/pkg/command/server.go b/services/idm/pkg/command/server.go index 87d058de913..237d2a0ec9d 100644 --- a/services/idm/pkg/command/server.go +++ b/services/idm/pkg/command/server.go @@ -85,9 +85,18 @@ func Server(cfg *config.Config) *cli.Command { return <-err } }, func(err error) { - logger.Error(). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) } diff --git a/services/idp/pkg/command/server.go b/services/idp/pkg/command/server.go index 9c12ac619f0..355f2f6ca0e 100644 --- a/services/idp/pkg/command/server.go +++ b/services/idp/pkg/command/server.go @@ -87,10 +87,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Str("transport", "http"). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/invitations/pkg/command/server.go b/services/invitations/pkg/command/server.go index 24f00038049..c2137e9d2d5 100644 --- a/services/invitations/pkg/command/server.go +++ b/services/invitations/pkg/command/server.go @@ -77,10 +77,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Err(err). - Str("transport", "http"). - Msg("Shutting down server") + if err != nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index 4a7df8d1802..2412c43f637 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -99,9 +99,17 @@ func Server(cfg *config.Config) *cli.Command { } }, func(err error) { - logger.Error(). - Err(err). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "nats"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "nats"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } natsServer.Shutdown() cancel() diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 4272419e84d..e6eaaf4c71f 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -98,10 +98,18 @@ func Server(cfg *config.Config) *cli.Command { return s.Run() }, func(err error) { - logger.Error(). - Err(err). - Str("server", c.Command.Name). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index 64fced6883d..eb12be1e3db 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -55,10 +55,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", cfg.Service.Name). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index 1054ea2e280..474f32735bc 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/pkg/command/server.go @@ -70,10 +70,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Err(err). - Str("transport", "http"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/postprocessing/pkg/command/server.go b/services/postprocessing/pkg/command/server.go index 51eba2a38fd..ef47a3bebee 100644 --- a/services/postprocessing/pkg/command/server.go +++ b/services/postprocessing/pkg/command/server.go @@ -75,10 +75,18 @@ func Server(cfg *config.Config) *cli.Command { return <-err } }, func(err error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("Shutting down server") + if err != nil { + logger.Info(). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) } diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index fb6af95e7d0..a8a47fe8d42 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -203,10 +203,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/search/pkg/command/server.go b/services/search/pkg/command/server.go index f098602a67b..05d38e9b859 100644 --- a/services/search/pkg/command/server.go +++ b/services/search/pkg/command/server.go @@ -63,10 +63,18 @@ func Server(cfg *config.Config) *cli.Command { } gr.Add(grpcServer.Run, func(_ error) { - logger.Error(). - Err(err). - Str("server", "grpc"). - Msg("shutting down server") + if err == nil { + logger.Info(). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) diff --git a/services/settings/pkg/command/server.go b/services/settings/pkg/command/server.go index 1e442ab6fd2..6b6ef631a8e 100644 --- a/services/settings/pkg/command/server.go +++ b/services/settings/pkg/command/server.go @@ -68,10 +68,18 @@ func Server(cfg *config.Config) *cli.Command { return fmt.Errorf("could not initialize http service: %w", err) } servers.Add(httpServer.Run, func(err error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) @@ -86,10 +94,18 @@ func Server(cfg *config.Config) *cli.Command { grpc.TraceProvider(traceProvider), ) servers.Add(grpcServer.Run, func(_ error) { - logger.Error(). - Err(err). - Str("server", "grpc"). - Msg("shutting down server") + if err == nil { + logger.Info(). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index 94d91a91c75..4948f813d37 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -70,10 +70,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", "reva"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 9a0c399160d..ed1621caee0 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", "reva"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index 7ed4bec2587..1311ef99be2 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", "reva"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index 2c2e058cb6d..88efdf05103 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -54,10 +54,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", "reva"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index db64d57a373..a100cc4f592 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -56,10 +56,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", "reva"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) @@ -100,11 +107,18 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("can't create event handler") } - gr.Add(eventSVC.Run, func(_ error) { - logger.Error(). - Err(err). - Str("server", cfg.Service.Name). - Msg("Shutting down event handler") + gr.Add(eventSVC.Run, func(err error) { + if err == nil { + logger.Info(). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "stream"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/thumbnails/pkg/command/server.go b/services/thumbnails/pkg/command/server.go index 4ad5ae0fdd7..075dc35a6dd 100644 --- a/services/thumbnails/pkg/command/server.go +++ b/services/thumbnails/pkg/command/server.go @@ -63,10 +63,17 @@ func Server(cfg *config.Config) *cli.Command { ) gr.Add(service.Run, func(_ error) { - logger.Error(). - Err(err). - Str("server", "grpc"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "grpc"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) @@ -104,10 +111,18 @@ func Server(cfg *config.Config) *cli.Command { } gr.Add(httpServer.Run, func(_ error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } + cancel() }) diff --git a/services/userlog/pkg/command/server.go b/services/userlog/pkg/command/server.go index b86ff9c3827..314d6c24090 100644 --- a/services/userlog/pkg/command/server.go +++ b/services/userlog/pkg/command/server.go @@ -133,10 +133,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index 115b58af3cd..7cabbfeeac0 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -67,10 +67,17 @@ func Server(cfg *config.Config) *cli.Command { return nil }, func(err error) { - logger.Error(). - Err(err). - Str("server", "reva"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "reva"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/web/pkg/command/server.go b/services/web/pkg/command/server.go index 73ceba8cce1..9fa3d395e42 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -83,10 +83,17 @@ func Server(cfg *config.Config) *cli.Command { } return err }, func(err error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/webdav/pkg/command/server.go b/services/webdav/pkg/command/server.go index 869b80f0ca1..dbe90821f4b 100644 --- a/services/webdav/pkg/command/server.go +++ b/services/webdav/pkg/command/server.go @@ -72,10 +72,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) diff --git a/services/webfinger/pkg/command/server.go b/services/webfinger/pkg/command/server.go index 0088349687d..966bf360bb1 100644 --- a/services/webfinger/pkg/command/server.go +++ b/services/webfinger/pkg/command/server.go @@ -85,10 +85,17 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(func() error { return server.Run() }, func(err error) { - logger.Error(). - Err(err). - Str("server", "http"). - Msg("Shutting down server") + if err == nil { + logger.Info(). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } else { + logger.Error().Err(err). + Str("transport", "http"). + Str("server", cfg.Service.Name). + Msg("Shutting down server") + } cancel() }) From 32287da09e35ff5ce414b0fbf4be29065c23778e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Fri, 25 Oct 2024 01:09:25 +0200 Subject: [PATCH 3/4] work on signal handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- ocis/pkg/runtime/service/service.go | 3 +-- services/app-registry/pkg/command/server.go | 7 +++++++ services/frontend/pkg/command/events.go | 2 +- services/nats/pkg/command/server.go | 8 ++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index afa6e6657c1..83cd6bd70a9 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -6,7 +6,6 @@ import ( "net" "net/http" "net/rpc" - "os" "sort" "strings" "time" @@ -515,7 +514,7 @@ func trap(s *Service, ctx context.Context) { } } s.Log.Debug().Str("service", "runtime service").Msgf("terminating with signal: %v", s) - os.Exit(0) + //os.Exit(0) // this seems to cause an early exit that prevents services from shitting down properly } // pingNats will attempt to connect to nats, blocking until a connection is established diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index 14f4ab277fc..0322d6c0eb6 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + gr.Add(func() error { + <-ctx.Done() + cancel() + return nil + }, func(err error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.AppRegistryConfigFromStruct(cfg, logger) diff --git a/services/frontend/pkg/command/events.go b/services/frontend/pkg/command/events.go index 83ca24c7cac..f80055da461 100644 --- a/services/frontend/pkg/command/events.go +++ b/services/frontend/pkg/command/events.go @@ -94,7 +94,7 @@ func ListenForEvents(ctx context.Context, cfg *config.Config, l log.Logger) erro } case <-ctx.Done(): l.Info().Msg("context cancelled") - return ctx.Err() + return nil } } } diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index 2412c43f637..6ad8a693174 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "fmt" + "time" "github.com/oklog/run" @@ -100,6 +101,13 @@ func Server(cfg *config.Config) *cli.Command { }, func(err error) { if err == nil { + logger.Info(). + Str("transport", "nats"). + Str("server", cfg.Service.Name). + Msg("letting other services deregister") + + time.Sleep(3 * time.Second) + logger.Info(). Str("transport", "nats"). Str("server", cfg.Service.Name). From 04632ad34cd2edcf26bbc247348058133d157b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 28 Oct 2024 11:22:58 +0100 Subject: [PATCH 4/4] make sure services have some time to deregister MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- ocis/pkg/runtime/service/service.go | 4 +++- services/app-provider/pkg/command/server.go | 7 +++++++ services/app-registry/pkg/command/server.go | 4 ++-- services/auth-app/pkg/command/server.go | 7 +++++++ services/auth-basic/pkg/command/server.go | 7 +++++++ services/auth-bearer/pkg/command/server.go | 7 +++++++ services/auth-machine/pkg/command/server.go | 7 +++++++ services/auth-service/pkg/command/server.go | 7 +++++++ services/frontend/pkg/command/server.go | 7 +++++++ services/gateway/pkg/command/server.go | 7 +++++++ services/groups/pkg/command/server.go | 7 +++++++ services/ocm/pkg/command/server.go | 7 +++++++ services/sharing/pkg/command/server.go | 7 +++++++ services/storage-publiclink/pkg/command/server.go | 7 +++++++ services/storage-shares/pkg/command/server.go | 7 +++++++ services/storage-system/pkg/command/server.go | 7 +++++++ services/storage-users/pkg/command/server.go | 7 +++++++ services/users/pkg/command/server.go | 7 +++++++ 18 files changed, 117 insertions(+), 3 deletions(-) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 83cd6bd70a9..f07fdf98820 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -6,6 +6,7 @@ import ( "net" "net/http" "net/rpc" + "os" "sort" "strings" "time" @@ -514,7 +515,8 @@ func trap(s *Service, ctx context.Context) { } } s.Log.Debug().Str("service", "runtime service").Msgf("terminating with signal: %v", s) - //os.Exit(0) // this seems to cause an early exit that prevents services from shitting down properly + time.Sleep(3 * time.Second) // give the services time to deregister + os.Exit(0) // FIXME this cause an early exit that prevents services from shitting down properly } // pingNats will attempt to connect to nats, blocking until a connection is established diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 4711b016023..73b7045c651 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.AppProviderConfigFromStruct(cfg) diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index 0322d6c0eb6..4758411a55c 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -41,11 +41,11 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled gr.Add(func() error { <-ctx.Done() - cancel() return nil - }, func(err error) { + }, func(_ error) { }) gr.Add(func() error { diff --git a/services/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index 96ead3230cf..e337309beb1 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -49,6 +49,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.AuthAppConfigFromStruct(cfg) diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index 37204df408e..0a8d8bf0cb8 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -54,6 +54,13 @@ func Server(cfg *config.Config) *cli.Command { } } + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.AuthBasicConfigFromStruct(cfg) diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index 8056387f96b..3ca39dc70e4 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.AuthBearerConfigFromStruct(cfg) diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 84d039a20ae..108948fd61a 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.AuthMachineConfigFromStruct(cfg) diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index 887cdd1cb43..192dc7576a0 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -46,6 +46,13 @@ func Server(cfg *config.Config) *cli.Command { rcfg := revaconfig.AuthMachineConfigFromStruct(cfg) + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { runtime.RunWithOptions(rcfg, pidFile, runtime.WithLogger(&logger.Logger), diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index e9597d7042e..bd4a05c545b 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -46,6 +46,13 @@ func Server(cfg *config.Config) *cli.Command { return err } + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") reg := registry.GetRegistry() diff --git a/services/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index 905db3bb3bc..2c909601f74 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.GatewayConfigFromStruct(cfg, logger) diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index b5d6030d2eb..ae4f7a045db 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -54,6 +54,13 @@ func Server(cfg *config.Config) *cli.Command { } } + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.GroupsConfigFromStruct(cfg) diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index eb12be1e3db..370d419185b 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -43,6 +43,13 @@ func Server(cfg *config.Config) *cli.Command { rCfg := revaconfig.OCMConfigFromStruct(cfg, logger) + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") reg := registry.GetRegistry() diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index 4948f813d37..7e12a76729b 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -54,6 +54,13 @@ func Server(cfg *config.Config) *cli.Command { } } + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg, err := revaconfig.SharingConfigFromStruct(cfg, logger) diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index ed1621caee0..9bc1283ad03 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.StoragePublicLinkConfigFromStruct(cfg) diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index 1311ef99be2..6de970d0e45 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.StorageSharesConfigFromStruct(cfg) diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index 88efdf05103..2f9ba7e5dea 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -41,6 +41,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.StorageSystemFromStruct(cfg) diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index a100cc4f592..a2aa036ceca 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -43,6 +43,13 @@ func Server(cfg *config.Config) *cli.Command { defer cancel() + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.StorageUsersConfigFromStruct(cfg) diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index 7cabbfeeac0..71d2d47129e 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -54,6 +54,13 @@ func Server(cfg *config.Config) *cli.Command { } } + // make sure the run group executes all interrupt handlers when the context is canceled + gr.Add(func() error { + <-ctx.Done() + return nil + }, func(_ error) { + }) + gr.Add(func() error { pidFile := path.Join(os.TempDir(), "revad-"+cfg.Service.Name+"-"+uuid.Must(uuid.NewV4()).String()+".pid") rCfg := revaconfig.UsersConfigFromStruct(cfg)