mirror of
https://github.com/minio/minio
synced 2024-10-14 11:52:56 +00:00
Support endpoints through env (#5952)
This commit is contained in:
parent
9c8b7306f5
commit
ac58283001
|
@ -22,6 +22,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
|
@ -65,6 +66,9 @@ ENVIRONMENT VARIABLES:
|
||||||
MINIO_ACCESS_KEY: Custom username or access key of minimum 3 characters in length.
|
MINIO_ACCESS_KEY: Custom username or access key of minimum 3 characters in length.
|
||||||
MINIO_SECRET_KEY: Custom password or secret key of minimum 8 characters in length.
|
MINIO_SECRET_KEY: Custom password or secret key of minimum 8 characters in length.
|
||||||
|
|
||||||
|
ENDPOINTS:
|
||||||
|
MINIO_ENDPOINTS: List of all endpoints delimited by ' '.
|
||||||
|
|
||||||
BROWSER:
|
BROWSER:
|
||||||
MINIO_BROWSER: To disable web browser access, set this value to "off".
|
MINIO_BROWSER: To disable web browser access, set this value to "off".
|
||||||
|
|
||||||
|
@ -73,12 +77,6 @@ ENVIRONMENT VARIABLES:
|
||||||
MINIO_CACHE_EXCLUDE: List of cache exclusion patterns delimited by ";".
|
MINIO_CACHE_EXCLUDE: List of cache exclusion patterns delimited by ";".
|
||||||
MINIO_CACHE_EXPIRY: Cache expiry duration in days.
|
MINIO_CACHE_EXPIRY: Cache expiry duration in days.
|
||||||
|
|
||||||
REGION:
|
|
||||||
MINIO_REGION: To set custom region. By default all regions are accepted.
|
|
||||||
|
|
||||||
UPDATE:
|
|
||||||
MINIO_UPDATE: To turn off in-place upgrades, set this value to "off".
|
|
||||||
|
|
||||||
DOMAIN:
|
DOMAIN:
|
||||||
MINIO_DOMAIN: To enable virtual-host-style requests, set this value to Minio host domain name.
|
MINIO_DOMAIN: To enable virtual-host-style requests, set this value to Minio host domain name.
|
||||||
|
|
||||||
|
@ -96,8 +94,9 @@ EXAMPLES:
|
||||||
$ export MINIO_DOMAIN=mydomain.com
|
$ export MINIO_DOMAIN=mydomain.com
|
||||||
$ {{.HelpName}} --address mydomain.com:9000 /mnt/export
|
$ {{.HelpName}} --address mydomain.com:9000 /mnt/export
|
||||||
|
|
||||||
4. Start minio server on 64 disks server.
|
4. Start minio server on 64 disks server with endpoints through environment variable.
|
||||||
$ {{.HelpName}} /mnt/export{1...64}
|
$ export MINIO_ENDPOINTS=/mnt/export{1...64}
|
||||||
|
$ {{.HelpName}}
|
||||||
|
|
||||||
5. Start distributed minio server on an 8 node setup with 8 drives each. Run following command on all the 8 nodes.
|
5. Start distributed minio server on an 8 node setup with 8 drives each. Run following command on all the 8 nodes.
|
||||||
$ export MINIO_ACCESS_KEY=minio
|
$ export MINIO_ACCESS_KEY=minio
|
||||||
|
@ -112,6 +111,16 @@ EXAMPLES:
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks if endpoints are either available through environment
|
||||||
|
// or command line, returns false if both fails.
|
||||||
|
func endpointsPresent(ctx *cli.Context) bool {
|
||||||
|
_, ok := os.LookupEnv("MINIO_ENDPOINTS")
|
||||||
|
if !ok {
|
||||||
|
ok = ctx.Args().Present()
|
||||||
|
}
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
func serverHandleCmdArgs(ctx *cli.Context) {
|
func serverHandleCmdArgs(ctx *cli.Context) {
|
||||||
// Handle common command args.
|
// Handle common command args.
|
||||||
handleCommonCmdArgs(ctx)
|
handleCommonCmdArgs(ctx)
|
||||||
|
@ -124,11 +133,17 @@ func serverHandleCmdArgs(ctx *cli.Context) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if len(ctx.Args()) > serverCommandLineArgsMax {
|
if len(ctx.Args()) > serverCommandLineArgsMax {
|
||||||
uErr := uiErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("Invalid total number of endpoints (%d) passed, supported upto 32 unique arguments", len(ctx.Args())))
|
uErr := uiErrInvalidErasureEndpoints(nil).Msg(fmt.Sprintf("Invalid total number of endpoints (%d) passed, supported upto 32 unique arguments",
|
||||||
|
len(ctx.Args())))
|
||||||
logger.FatalIf(uErr, "Unable to validate passed endpoints")
|
logger.FatalIf(uErr, "Unable to validate passed endpoints")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endpoints := strings.Fields(os.Getenv("MINIO_ENDPOINTS"))
|
||||||
|
if len(endpoints) > 0 {
|
||||||
|
globalMinioAddr, globalEndpoints, setupType, globalXLSetCount, globalXLSetDriveCount, err = createServerEndpoints(serverAddr, endpoints...)
|
||||||
|
} else {
|
||||||
globalMinioAddr, globalEndpoints, setupType, globalXLSetCount, globalXLSetDriveCount, err = createServerEndpoints(serverAddr, ctx.Args()...)
|
globalMinioAddr, globalEndpoints, setupType, globalXLSetCount, globalXLSetDriveCount, err = createServerEndpoints(serverAddr, ctx.Args()...)
|
||||||
|
}
|
||||||
logger.FatalIf(err, "Invalid command line arguments")
|
logger.FatalIf(err, "Invalid command line arguments")
|
||||||
|
|
||||||
globalMinioHost, globalMinioPort = mustSplitHostPort(globalMinioAddr)
|
globalMinioHost, globalMinioPort = mustSplitHostPort(globalMinioAddr)
|
||||||
|
@ -164,7 +179,7 @@ func init() {
|
||||||
|
|
||||||
// serverMain handler called for 'minio server' command.
|
// serverMain handler called for 'minio server' command.
|
||||||
func serverMain(ctx *cli.Context) {
|
func serverMain(ctx *cli.Context) {
|
||||||
if (!ctx.IsSet("sets") && !ctx.Args().Present()) || ctx.Args().First() == "help" {
|
if ctx.Args().First() == "help" || !endpointsPresent(ctx) {
|
||||||
cli.ShowCommandHelpAndExit(ctx, "server", 1)
|
cli.ShowCommandHelpAndExit(ctx, "server", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue