mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
support reading systemctl config automatically on baremetal setups (#15066)
this allows for customers to use `mc admin service restart` directly even when performing RPM, DEB upgrades. Upon such 'restart' after upgrade MinIO will re-read the /etc/default/minio for any newer environment variables. As long as `MINIO_CONFIG_ENV_FILE=/etc/default/minio` is set, this is honored.
This commit is contained in:
@@ -526,9 +526,6 @@ func parsEnvEntry(envEntry string) (envKV, error) {
|
||||
func minioEnvironFromFile(envConfigFile string) ([]envKV, error) {
|
||||
f, err := os.Open(envConfigFile)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) { // ignore if file doesn't exist.
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
@@ -624,7 +621,7 @@ func loadEnvVarsFromFiles() {
|
||||
|
||||
if env.IsSet(config.EnvConfigEnvFile) {
|
||||
ekvs, err := minioEnvironFromFile(env.Get(config.EnvConfigEnvFile, ""))
|
||||
if err != nil {
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
logger.Fatal(err, "Unable to read the config environment file")
|
||||
}
|
||||
for _, ekv := range ekvs {
|
||||
|
||||
@@ -138,6 +138,13 @@ func serverCmdArgs(ctx *cli.Context) []string {
|
||||
logger.FatalIf(err, "Unable to validate passed arguments in %s:%s",
|
||||
config.EnvArgs, os.Getenv(config.EnvArgs))
|
||||
}
|
||||
if v == "" {
|
||||
v, _, _, err = env.LookupEnv(config.EnvVolumes)
|
||||
if err != nil {
|
||||
logger.FatalIf(err, "Unable to validate passed arguments in %s:%s",
|
||||
config.EnvVolumes, os.Getenv(config.EnvVolumes))
|
||||
}
|
||||
}
|
||||
if v == "" {
|
||||
// Fall back to older environment value MINIO_ENDPOINTS
|
||||
v, _, _, err = env.LookupEnv(config.EnvEndpoints)
|
||||
@@ -422,12 +429,12 @@ func serverMain(ctx *cli.Context) {
|
||||
erasureSelfTest()
|
||||
compressSelfTest()
|
||||
|
||||
// Handle all server command args.
|
||||
serverHandleCmdArgs(ctx)
|
||||
|
||||
// Handle all server environment vars.
|
||||
serverHandleEnvVars()
|
||||
|
||||
// Handle all server command args.
|
||||
serverHandleCmdArgs(ctx)
|
||||
|
||||
// Set node name, only set for distributed setup.
|
||||
globalConsoleSys.SetNodeName(globalLocalNodeName)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user