From 98bb6ebf5936140bbb14ec64c05520fd1477cb0f Mon Sep 17 00:00:00 2001 From: Jude Hung Date: Fri, 22 Nov 2024 04:59:59 +0000 Subject: [PATCH] feat: refactor services to build monolithic service easily (#5010) * feat: refactor core services to build monolithic service easily fixes https://github.com/edgexfoundry/edgex-go/issues/5009 There is a user requirement that prefers to combine all core services into a single monolithic service. To easily achieve this based on current code structure, refactor following codes: 1. Change the signature of main function for each core services to allow pass os arguments rather than directly parse `os.Args[1:]`. With this change, the single monolithic service can alter the behavior of each individual internal services by passing different arguments. 2. Remove `os.Exit(0)` by end of a successful run of common_config_bootstrapper. This call is redundant and will force monolithic service to exit directly. Signed-off-by: Jude Hung * feat: Apply the changes to all edgex services Change the signature of main function for each edgex services to allow pass os arguments rather than directly parse os.Args[1:]. With this change, the single monolithic service can alter the behavior of each individual internal services by passing different arguments. Signed-off-by: Jude Hung --------- Signed-off-by: Jude Hung --- cmd/core-command/main.go | 3 ++- cmd/core-common-config-bootstrapper/main.go | 4 +++- cmd/core-data/main.go | 3 ++- cmd/core-keeper/main.go | 3 ++- cmd/core-metadata/main.go | 3 ++- cmd/secrets-config/main.go | 2 +- cmd/security-bootstrapper/main.go | 2 +- cmd/security-file-token-provider/main.go | 3 ++- cmd/security-proxy-auth/main.go | 3 ++- cmd/security-secretstore-setup/main.go | 3 ++- cmd/security-spiffe-token-provider/main.go | 3 ++- cmd/support-notifications/main.go | 3 ++- cmd/support-scheduler/main.go | 3 ++- internal/core/command/main.go | 7 +++---- internal/core/common_config/main.go | 7 +++---- internal/core/data/main.go | 10 ++++------ internal/core/keeper/main.go | 10 ++++------ internal/core/metadata/main.go | 10 ++++------ internal/security/bootstrapper/main.go | 4 ++-- internal/security/config/main.go | 6 ++---- internal/security/fileprovider/main.go | 8 ++++---- internal/security/proxyauth/main.go | 10 ++++------ internal/security/secretstore/main.go | 6 +++--- internal/security/spiffetokenprovider/main.go | 4 ++-- internal/support/notifications/main.go | 10 ++++------ internal/support/scheduler/main.go | 10 ++++------ 26 files changed, 68 insertions(+), 72 deletions(-) diff --git a/cmd/core-command/main.go b/cmd/core-command/main.go index a112dd78a1..56805a9733 100644 --- a/cmd/core-command/main.go +++ b/cmd/core-command/main.go @@ -17,6 +17,7 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/core/command" @@ -25,5 +26,5 @@ import ( func main() { ctx, cancel := context.WithCancel(context.Background()) - command.Main(ctx, cancel, echo.New()) + command.Main(ctx, cancel, echo.New(), os.Args[1:]) } diff --git a/cmd/core-common-config-bootstrapper/main.go b/cmd/core-common-config-bootstrapper/main.go index cdb8b73069..257b66b96f 100644 --- a/cmd/core-common-config-bootstrapper/main.go +++ b/cmd/core-common-config-bootstrapper/main.go @@ -15,10 +15,12 @@ package main import ( "context" + "os" + "github.com/edgexfoundry/edgex-go/internal/core/common_config" ) func main() { ctx, cancel := context.WithCancel(context.Background()) - common_config.Main(ctx, cancel) + common_config.Main(ctx, cancel, os.Args[1:]) } diff --git a/cmd/core-data/main.go b/cmd/core-data/main.go index 75e6b5ab56..67ea2ba237 100644 --- a/cmd/core-data/main.go +++ b/cmd/core-data/main.go @@ -17,6 +17,7 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/core/data" @@ -25,5 +26,5 @@ import ( func main() { ctx, cancel := context.WithCancel(context.Background()) - data.Main(ctx, cancel, echo.New()) + data.Main(ctx, cancel, echo.New(), os.Args[1:]) } diff --git a/cmd/core-keeper/main.go b/cmd/core-keeper/main.go index bdd1c8a17c..c1c0e48935 100644 --- a/cmd/core-keeper/main.go +++ b/cmd/core-keeper/main.go @@ -7,6 +7,7 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/core/keeper" @@ -15,5 +16,5 @@ import ( func main() { ctx, cancel := context.WithCancel(context.Background()) - keeper.Main(ctx, cancel, echo.New()) + keeper.Main(ctx, cancel, echo.New(), os.Args[1:]) } diff --git a/cmd/core-metadata/main.go b/cmd/core-metadata/main.go index 65ad842dee..911a815b35 100644 --- a/cmd/core-metadata/main.go +++ b/cmd/core-metadata/main.go @@ -16,6 +16,7 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/core/metadata" @@ -24,5 +25,5 @@ import ( func main() { ctx, cancel := context.WithCancel(context.Background()) - metadata.Main(ctx, cancel, echo.New()) + metadata.Main(ctx, cancel, echo.New(), os.Args[1:]) } diff --git a/cmd/secrets-config/main.go b/cmd/secrets-config/main.go index 7375b7dfb0..7237a35123 100644 --- a/cmd/secrets-config/main.go +++ b/cmd/secrets-config/main.go @@ -16,6 +16,6 @@ import ( func main() { os.Setenv("LOGLEVEL", "ERROR") // Workaround for https://github.com/edgexfoundry/edgex-go/issues/2922 ctx, cancel := context.WithCancel(context.Background()) - exitStatusCode := config.Main(ctx, cancel) + exitStatusCode := config.Main(ctx, cancel, os.Args[1:]) os.Exit(exitStatusCode) } diff --git a/cmd/security-bootstrapper/main.go b/cmd/security-bootstrapper/main.go index 6e49319805..d847acc9ec 100644 --- a/cmd/security-bootstrapper/main.go +++ b/cmd/security-bootstrapper/main.go @@ -28,5 +28,5 @@ func main() { _ = os.Unsetenv("EDGEX_PROFILE") ctx, cancel := context.WithCancel(context.Background()) - bootstrapper.Main(ctx, cancel) + bootstrapper.Main(ctx, cancel, os.Args[1:]) } diff --git a/cmd/security-file-token-provider/main.go b/cmd/security-file-token-provider/main.go index d4fd08e0b4..f91cc45b58 100644 --- a/cmd/security-file-token-provider/main.go +++ b/cmd/security-file-token-provider/main.go @@ -17,11 +17,12 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/security/fileprovider" ) func main() { ctx, cancel := context.WithCancel(context.Background()) - fileprovider.Main(ctx, cancel) + fileprovider.Main(ctx, cancel, os.Args[1:]) } diff --git a/cmd/security-proxy-auth/main.go b/cmd/security-proxy-auth/main.go index 5c1555b942..f0865a2c46 100644 --- a/cmd/security-proxy-auth/main.go +++ b/cmd/security-proxy-auth/main.go @@ -16,6 +16,7 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/security/proxyauth" @@ -24,5 +25,5 @@ import ( func main() { ctx, cancel := context.WithCancel(context.Background()) - proxyauth.Main(ctx, cancel, echo.New()) + proxyauth.Main(ctx, cancel, echo.New(), os.Args[1:]) } diff --git a/cmd/security-secretstore-setup/main.go b/cmd/security-secretstore-setup/main.go index 1d68fa9e3b..d364ac5da6 100644 --- a/cmd/security-secretstore-setup/main.go +++ b/cmd/security-secretstore-setup/main.go @@ -21,11 +21,12 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/security/secretstore" ) func main() { ctx, cancel := context.WithCancel(context.Background()) - secretstore.Main(ctx, cancel) + secretstore.Main(ctx, cancel, os.Args[1:]) } diff --git a/cmd/security-spiffe-token-provider/main.go b/cmd/security-spiffe-token-provider/main.go index 527627b3a2..69b77bfef5 100644 --- a/cmd/security-spiffe-token-provider/main.go +++ b/cmd/security-spiffe-token-provider/main.go @@ -17,11 +17,12 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/security/spiffetokenprovider" ) func main() { ctx, cancel := context.WithCancel(context.Background()) - spiffetokenprovider.Main(ctx, cancel) + spiffetokenprovider.Main(ctx, cancel, os.Args[1:]) } diff --git a/cmd/support-notifications/main.go b/cmd/support-notifications/main.go index 6537459849..3809c34471 100644 --- a/cmd/support-notifications/main.go +++ b/cmd/support-notifications/main.go @@ -23,6 +23,7 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/support/notifications" @@ -31,5 +32,5 @@ import ( func main() { ctx, cancel := context.WithCancel(context.Background()) - notifications.Main(ctx, cancel, echo.New()) + notifications.Main(ctx, cancel, echo.New(), os.Args[1:]) } diff --git a/cmd/support-scheduler/main.go b/cmd/support-scheduler/main.go index f1403db071..4ea3a52047 100644 --- a/cmd/support-scheduler/main.go +++ b/cmd/support-scheduler/main.go @@ -16,6 +16,7 @@ package main import ( "context" + "os" "github.com/edgexfoundry/edgex-go/internal/support/scheduler" @@ -24,5 +25,5 @@ import ( func main() { ctx, cancel := context.WithCancel(context.Background()) - scheduler.Main(ctx, cancel, echo.New()) + scheduler.Main(ctx, cancel, echo.New(), os.Args[1:]) } diff --git a/internal/core/command/main.go b/internal/core/command/main.go index d24b62a93d..c0c644902b 100644 --- a/internal/core/command/main.go +++ b/internal/core/command/main.go @@ -18,7 +18,6 @@ package command import ( "context" - "os" "sync" "time" @@ -41,7 +40,7 @@ import ( "github.com/labstack/echo/v4" ) -func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { +func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo, args []string) { startupTimer := startup.NewStartUpTimer(common.CoreCommandServiceKey) // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, @@ -49,10 +48,10 @@ func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/core/common_config/main.go b/internal/core/common_config/main.go index 60a1c26c1b..631959ddf3 100644 --- a/internal/core/common_config/main.go +++ b/internal/core/common_config/main.go @@ -42,7 +42,7 @@ const ( commonConfigDone = "IsCommonConfigReady" ) -func Main(ctx context.Context, cancel context.CancelFunc) { +func Main(ctx context.Context, cancel context.CancelFunc, args []string) { startupTimer := startup.NewStartUpTimer(common.CoreCommonConfigServiceKey) // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, @@ -50,12 +50,12 @@ func Main(ctx context.Context, cancel context.CancelFunc) { // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // // TODO: figure out how to eliminate registry and profile flags f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) var wg sync.WaitGroup translateInterruptToCancel(ctx, &wg, cancel) @@ -130,7 +130,6 @@ func Main(ctx context.Context, cancel context.CancelFunc) { } lc.Info("Core Common Config exiting") - os.Exit(0) } // translateInterruptToCancel spawns a go routine to translate the receipt of a SIGTERM signal to a call to cancel diff --git a/internal/core/data/main.go b/internal/core/data/main.go index 036fa9295e..e893577336 100644 --- a/internal/core/data/main.go +++ b/internal/core/data/main.go @@ -18,8 +18,6 @@ package data import ( "context" - "os" - "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap" "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/flags" "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/handlers" @@ -38,18 +36,18 @@ import ( "github.com/labstack/echo/v4" ) -func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { +func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo, args []string) { startupTimer := startup.NewStartUpTimer(common.CoreDataServiceKey) - // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, + // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, // by inserting service specific flag prior to call to commonFlags.Parse(). // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/core/keeper/main.go b/internal/core/keeper/main.go index 9f6e12b913..4b34be44e6 100644 --- a/internal/core/keeper/main.go +++ b/internal/core/keeper/main.go @@ -7,8 +7,6 @@ package keeper import ( "context" - "os" - "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap" "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/flags" "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/handlers" @@ -28,18 +26,18 @@ import ( "github.com/labstack/echo/v4" ) -func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { +func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo, args []string) { startupTimer := startup.NewStartUpTimer(constants.CoreKeeperServiceKey) - // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, + // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, // by inserting service specific flag prior to call to commonFlags.Parse(). // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/core/metadata/main.go b/internal/core/metadata/main.go index 68e4e68f1b..ac5c152616 100644 --- a/internal/core/metadata/main.go +++ b/internal/core/metadata/main.go @@ -18,8 +18,6 @@ package metadata import ( "context" - "os" - "github.com/edgexfoundry/edgex-go" "github.com/edgexfoundry/edgex-go/internal/core/metadata/config" "github.com/edgexfoundry/edgex-go/internal/core/metadata/container" @@ -39,18 +37,18 @@ import ( "github.com/labstack/echo/v4" ) -func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { +func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo, args []string) { startupTimer := startup.NewStartUpTimer(common.CoreMetaDataServiceKey) - // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, + // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, // by inserting service specific flag prior to call to commonFlags.Parse(). // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/security/bootstrapper/main.go b/internal/security/bootstrapper/main.go index 974f554d0e..8d6d669091 100644 --- a/internal/security/bootstrapper/main.go +++ b/internal/security/bootstrapper/main.go @@ -45,7 +45,7 @@ const ( ) // Main function is the wrapper for the security bootstrapper main -func Main(ctx context.Context, cancel context.CancelFunc) { +func Main(ctx context.Context, cancel context.CancelFunc, args []string) { // service key for this bootstrapper service startupTimer := startup.NewStartUpTimer(common.SecurityBootstrapperKey) @@ -53,7 +53,7 @@ func Main(ctx context.Context, cancel context.CancelFunc) { // the common flags so we are using our own implementation of the CommonFlags interface f := bootstrapper.NewCommonFlags() - f.Parse(os.Args[1:]) + f.Parse(args) // find out the subcommand name before assigning the real concrete configuration // bootstrapRedis has its own configuration settings diff --git a/internal/security/config/main.go b/internal/security/config/main.go index 1abbb527dd..0358ada623 100644 --- a/internal/security/config/main.go +++ b/internal/security/config/main.go @@ -16,8 +16,6 @@ package config import ( "context" - "os" - "github.com/edgexfoundry/go-mod-core-contracts/v4/clients/logger" "github.com/edgexfoundry/go-mod-core-contracts/v4/common" @@ -38,14 +36,14 @@ import ( const securitySecretsConfigServiceKey = "secrets-config" // Main function called from cmd/secrets-config -func Main(ctx context.Context, cancel context.CancelFunc) int { +func Main(ctx context.Context, cancel context.CancelFunc, args []string) int { startupTimer := startup.NewStartUpTimer(securitySecretsConfigServiceKey) // Common Command-line flags have been moved to command.CommonFlags, but this service doesn't use all // the common flags so we are using our own implementation of the CommonFlags interface f := command.NewCommonFlags() - f.Parse(os.Args[1:]) + f.Parse(args) lc := logger.NewClient(securitySecretsConfigServiceKey, models.ErrorLog) configuration := &config.ConfigurationStruct{} diff --git a/internal/security/fileprovider/main.go b/internal/security/fileprovider/main.go index 06bba26299..9e0012794b 100644 --- a/internal/security/fileprovider/main.go +++ b/internal/security/fileprovider/main.go @@ -32,19 +32,19 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/common" ) -func Main(ctx context.Context, cancel context.CancelFunc) { +func Main(ctx context.Context, cancel context.CancelFunc, args []string) { startupTimer := startup.NewStartUpTimer(common.SecurityFileTokenProviderServiceKey) - // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, + // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, // by inserting service specific flag prior to call to commonFlags.Parse(). // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/security/proxyauth/main.go b/internal/security/proxyauth/main.go index dbb5b00672..74972b9b00 100644 --- a/internal/security/proxyauth/main.go +++ b/internal/security/proxyauth/main.go @@ -18,8 +18,6 @@ package proxyauth import ( "context" - "os" - "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap" "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/flags" "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap/handlers" @@ -39,18 +37,18 @@ import ( const SecurityProxyAuthServiceKey = "security-proxy-auth" -func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { +func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo, args []string) { startupTimer := startup.NewStartUpTimer(common.CoreCommandServiceKey) - // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, + // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, // by inserting service specific flag prior to call to commonFlags.Parse(). // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/security/secretstore/main.go b/internal/security/secretstore/main.go index 02a479d071..ab8dda1546 100644 --- a/internal/security/secretstore/main.go +++ b/internal/security/secretstore/main.go @@ -38,7 +38,7 @@ import ( "github.com/edgexfoundry/go-mod-core-contracts/v4/common" ) -func Main(ctx context.Context, cancel context.CancelFunc) { +func Main(ctx context.Context, cancel context.CancelFunc, args []string) { startupTimer := startup.NewStartUpTimer(common.SecuritySecretStoreSetupServiceKey) var insecureSkipVerify bool @@ -52,13 +52,13 @@ func Main(ctx context.Context, cancel context.CancelFunc) { " --secretStoreInterval= Indicates how long the program will pause between the secret store initialization attempts until it succeeds", ) - if len(os.Args) < 2 { + if len(args) < 1 { f.Help() } f.FlagSet.BoolVar(&insecureSkipVerify, "insecureSkipVerify", false, "") f.FlagSet.IntVar(&secretStoreInterval, "secretStoreInterval", 30, "") - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/security/spiffetokenprovider/main.go b/internal/security/spiffetokenprovider/main.go index 13910e933e..b07360bd29 100644 --- a/internal/security/spiffetokenprovider/main.go +++ b/internal/security/spiffetokenprovider/main.go @@ -31,11 +31,11 @@ import ( "github.com/edgexfoundry/go-mod-bootstrap/v4/di" ) -func Main(ctx context.Context, cancel context.CancelFunc) { +func Main(ctx context.Context, cancel context.CancelFunc, args []string) { startupTimer := startup.NewStartUpTimer(common.SecuritySpiffeTokenProviderKey) f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/support/notifications/main.go b/internal/support/notifications/main.go index 3ce887d36f..2506498065 100644 --- a/internal/support/notifications/main.go +++ b/internal/support/notifications/main.go @@ -24,8 +24,6 @@ package notifications import ( "context" - "os" - "github.com/edgexfoundry/go-mod-bootstrap/v4/config" "github.com/edgexfoundry/edgex-go" @@ -44,18 +42,18 @@ import ( "github.com/labstack/echo/v4" ) -func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { +func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo, args []string) { startupTimer := startup.NewStartUpTimer(common.SupportNotificationsServiceKey) - // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, + // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, // by inserting service specific flag prior to call to commonFlags.Parse(). // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := ¬ificationsConfig.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{ diff --git a/internal/support/scheduler/main.go b/internal/support/scheduler/main.go index 21200bbb1e..ae490b6d3f 100644 --- a/internal/support/scheduler/main.go +++ b/internal/support/scheduler/main.go @@ -16,8 +16,6 @@ package scheduler import ( "context" - "os" - "github.com/labstack/echo/v4" "github.com/edgexfoundry/go-mod-bootstrap/v4/bootstrap" @@ -35,18 +33,18 @@ import ( "github.com/edgexfoundry/edgex-go/internal/support/scheduler/container" ) -func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo) { +func Main(ctx context.Context, cancel context.CancelFunc, router *echo.Echo, args []string) { startupTimer := startup.NewStartUpTimer(common.SupportSchedulerServiceKey) - // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here, + // All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be added here, // by inserting service specific flag prior to call to commonFlags.Parse(). // Example: // flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....") // .... - // flags.Parse(os.Args[1:]) + // flags.Parse(args) // f := flags.New() - f.Parse(os.Args[1:]) + f.Parse(args) configuration := &config.ConfigurationStruct{} dic := di.NewContainer(di.ServiceConstructorMap{