diff --git a/cmd/globals.go b/cmd/globals.go index e1b943b27..eaa0508e5 100644 --- a/cmd/globals.go +++ b/cmd/globals.go @@ -110,11 +110,11 @@ var ( // Minio server user agent string. globalServerUserAgent = "Minio/" + ReleaseTag + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")" - // Access key passed from the environment - globalEnvAccessKey = os.Getenv("MINIO_ACCESS_KEY") + // Global server's access key + globalEnvAccessKey = "" - // Secret key passed from the environment - globalEnvSecretKey = os.Getenv("MINIO_SECRET_KEY") + // Global server's secret key + globalEnvSecretKey = "" // url.URL endpoints of disks that belong to the object storage. globalEndpoints = []*url.URL{} diff --git a/cmd/main.go b/cmd/main.go index db214201e..0038042ea 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -190,6 +190,8 @@ func minioInit(ctx *cli.Context) { enableLoggers() // Fetch access keys from environment variables and update the config. + globalEnvAccessKey = os.Getenv("MINIO_ACCESS_KEY") + globalEnvSecretKey = os.Getenv("MINIO_SECRET_KEY") if globalEnvAccessKey != "" && globalEnvSecretKey != "" { // Set new credentials. serverConfig.SetCredential(credential{ @@ -210,7 +212,7 @@ func minioInit(ctx *cli.Context) { } // Main main for minio server. -func Main() { +func Main(args []string, exitFn func(int)) { app := registerApp() app.Before = func(c *cli.Context) error { // Valid input arguments to main. @@ -224,5 +226,7 @@ func Main() { } // Run the app - exit on error. - app.RunAndExitOnError() + if err := app.Run(args); err != nil { + exitFn(1) + } } diff --git a/main.go b/main.go index 03814d857..7c635a6b7 100644 --- a/main.go +++ b/main.go @@ -22,8 +22,12 @@ package main // import "github.com/minio/minio" -import minio "github.com/minio/minio/cmd" +import ( + "os" + + minio "github.com/minio/minio/cmd" +) func main() { - minio.Main() + minio.Main(os.Args, os.Exit) }