mirror of
https://github.com/minio/minio.git
synced 2025-02-03 01:46:00 -05:00
Dont start console service if MINIO_BROWSER=off (#20374)
By default, even if MINIO_BROWSER=off set code tries to get free port available for the console. Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
This commit is contained in:
parent
9b79eec29e
commit
6224849fd1
@ -461,6 +461,7 @@ func handleCommonArgs(ctxt serverCtxt) {
|
|||||||
certsDir := ctxt.CertsDir
|
certsDir := ctxt.CertsDir
|
||||||
certsSet := ctxt.certsDirSet
|
certsSet := ctxt.certsDirSet
|
||||||
|
|
||||||
|
if globalBrowserEnabled {
|
||||||
if consoleAddr == "" {
|
if consoleAddr == "" {
|
||||||
p, err := xnet.GetFreePort()
|
p, err := xnet.GetFreePort()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -481,6 +482,7 @@ func handleCommonArgs(ctxt serverCtxt) {
|
|||||||
if consoleAddr == addr {
|
if consoleAddr == addr {
|
||||||
logger.FatalIf(errors.New("--console-address cannot be same as --address"), "Unable to start the server")
|
logger.FatalIf(errors.New("--console-address cannot be same as --address"), "Unable to start the server")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
globalMinioHost, globalMinioPort = mustSplitHostPort(addr)
|
globalMinioHost, globalMinioPort = mustSplitHostPort(addr)
|
||||||
if globalMinioPort == "0" {
|
if globalMinioPort == "0" {
|
||||||
@ -492,7 +494,9 @@ func handleCommonArgs(ctxt serverCtxt) {
|
|||||||
globalDynamicAPIPort = true
|
globalDynamicAPIPort = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if globalBrowserEnabled {
|
||||||
globalMinioConsoleHost, globalMinioConsolePort = mustSplitHostPort(consoleAddr)
|
globalMinioConsoleHost, globalMinioConsolePort = mustSplitHostPort(consoleAddr)
|
||||||
|
}
|
||||||
|
|
||||||
if globalMinioPort == globalMinioConsolePort {
|
if globalMinioPort == globalMinioConsolePort {
|
||||||
logger.FatalIf(errors.New("--console-address port cannot be same as --address port"), "Unable to start the server")
|
logger.FatalIf(errors.New("--console-address port cannot be same as --address port"), "Unable to start the server")
|
||||||
@ -696,12 +700,16 @@ func loadEnvVarsFromFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func serverHandleEnvVars() {
|
func serverHandleEarlyEnvVars() {
|
||||||
var err error
|
var err error
|
||||||
globalBrowserEnabled, err = config.ParseBool(env.Get(config.EnvBrowser, config.EnableOn))
|
globalBrowserEnabled, err = config.ParseBool(env.Get(config.EnvBrowser, config.EnableOn))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal(config.ErrInvalidBrowserValue(err), "Invalid MINIO_BROWSER value in environment variable")
|
logger.Fatal(config.ErrInvalidBrowserValue(err), "Invalid MINIO_BROWSER value in environment variable")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func serverHandleEnvVars() {
|
||||||
|
var err error
|
||||||
if globalBrowserEnabled {
|
if globalBrowserEnabled {
|
||||||
if redirectURL := env.Get(config.EnvBrowserRedirectURL, ""); redirectURL != "" {
|
if redirectURL := env.Get(config.EnvBrowserRedirectURL, ""); redirectURL != "" {
|
||||||
u, err := xnet.ParseHTTPURL(redirectURL)
|
u, err := xnet.ParseHTTPURL(redirectURL)
|
||||||
|
@ -773,6 +773,9 @@ func serverMain(ctx *cli.Context) {
|
|||||||
// Always load ENV variables from files first.
|
// Always load ENV variables from files first.
|
||||||
loadEnvVarsFromFiles()
|
loadEnvVarsFromFiles()
|
||||||
|
|
||||||
|
// Handle early server environment vars
|
||||||
|
serverHandleEarlyEnvVars()
|
||||||
|
|
||||||
// Handle all server command args and build the disks layout
|
// Handle all server command args and build the disks layout
|
||||||
bootstrapTrace("serverHandleCmdArgs", func() {
|
bootstrapTrace("serverHandleCmdArgs", func() {
|
||||||
err := buildServerCtxt(ctx, &globalServerCtxt)
|
err := buildServerCtxt(ctx, &globalServerCtxt)
|
||||||
|
@ -81,9 +81,11 @@ func handleSignals() {
|
|||||||
shutdownLogIf(context.Background(), objAPI.Shutdown(context.Background()))
|
shutdownLogIf(context.Background(), objAPI.Shutdown(context.Background()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if globalBrowserEnabled {
|
||||||
if srv := newConsoleServerFn(); srv != nil {
|
if srv := newConsoleServerFn(); srv != nil {
|
||||||
shutdownLogIf(context.Background(), srv.Shutdown())
|
shutdownLogIf(context.Background(), srv.Shutdown())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if globalEventNotifier != nil {
|
if globalEventNotifier != nil {
|
||||||
globalEventNotifier.RemoveAllBucketTargets()
|
globalEventNotifier.RemoveAllBucketTargets()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user