Browse Source

Added a "-conf_dir" option to customize *.toml configuration file directory.

fix https://github.com/chrislusf/seaweedfs/issues/2753
pull/2781/head
chrislu 3 years ago
parent
commit
3da2b83b38
  1. 15
      weed/util/config.go
  2. 3
      weed/weed.go

15
weed/util/config.go

@ -9,6 +9,20 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
)
var (
ConfigurationFileDirectory DirectoryValueType
)
type DirectoryValueType string
func (s *DirectoryValueType) Set(value string) error {
*s = DirectoryValueType(value)
return nil
}
func (s *DirectoryValueType) String() string {
return string(*s)
}
type Configuration interface {
GetString(key string) string
GetBool(key string) bool
@ -21,6 +35,7 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) {
// find a filer store
viper.SetConfigName(configFileName) // name of config file (without extension)
viper.AddConfigPath(ResolvePath(ConfigurationFileDirectory.String())) // path to look for the config file in
viper.AddConfigPath(".") // optionally look for config in the working directory
viper.AddConfigPath("$HOME/.seaweedfs") // call multiple times to add many search paths
viper.AddConfigPath("/usr/local/etc/seaweedfs/") // search path for bsd-style config directory in

3
weed/weed.go

@ -4,6 +4,7 @@ import (
"embed"
"fmt"
weed_server "github.com/chrislusf/seaweedfs/weed/server"
"github.com/chrislusf/seaweedfs/weed/util"
flag "github.com/chrislusf/seaweedfs/weed/util/fla9"
"io"
"io/fs"
@ -40,6 +41,8 @@ var static embed.FS
func init() {
weed_server.StaticFS, _ = fs.Sub(static, "static")
flag.Var(&util.ConfigurationFileDirectory, "conf_dir", "directory with toml configuration files")
}
func main() {

Loading…
Cancel
Save