mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 06:47:53 +08:00
Added a "-conf_dir" option to customize *.toml configuration file directory.
fix https://github.com/chrislusf/seaweedfs/issues/2753
This commit is contained in:
@@ -9,6 +9,20 @@ import (
|
|||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"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 {
|
type Configuration interface {
|
||||||
GetString(key string) string
|
GetString(key string) string
|
||||||
GetBool(key string) bool
|
GetBool(key string) bool
|
||||||
@@ -20,11 +34,12 @@ type Configuration interface {
|
|||||||
func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
||||||
|
|
||||||
// find a filer store
|
// find a filer store
|
||||||
viper.SetConfigName(configFileName) // name of config file (without extension)
|
viper.SetConfigName(configFileName) // name of config file (without extension)
|
||||||
viper.AddConfigPath(".") // optionally look for config in the working directory
|
viper.AddConfigPath(ResolvePath(ConfigurationFileDirectory.String())) // path to look for the config file in
|
||||||
viper.AddConfigPath("$HOME/.seaweedfs") // call multiple times to add many search paths
|
viper.AddConfigPath(".") // optionally look for config in the working directory
|
||||||
viper.AddConfigPath("/usr/local/etc/seaweedfs/") // search path for bsd-style config directory in
|
viper.AddConfigPath("$HOME/.seaweedfs") // call multiple times to add many search paths
|
||||||
viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
|
viper.AddConfigPath("/usr/local/etc/seaweedfs/") // search path for bsd-style config directory in
|
||||||
|
viper.AddConfigPath("/etc/seaweedfs/") // path to look for the config file in
|
||||||
|
|
||||||
if err := viper.MergeInConfig(); err != nil { // Handle errors reading the config file
|
if err := viper.MergeInConfig(); err != nil { // Handle errors reading the config file
|
||||||
if strings.Contains(err.Error(), "Not Found") {
|
if strings.Contains(err.Error(), "Not Found") {
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
weed_server "github.com/chrislusf/seaweedfs/weed/server"
|
weed_server "github.com/chrislusf/seaweedfs/weed/server"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
flag "github.com/chrislusf/seaweedfs/weed/util/fla9"
|
flag "github.com/chrislusf/seaweedfs/weed/util/fla9"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
@@ -40,6 +41,8 @@ var static embed.FS
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
weed_server.StaticFS, _ = fs.Sub(static, "static")
|
weed_server.StaticFS, _ = fs.Sub(static, "static")
|
||||||
|
|
||||||
|
flag.Var(&util.ConfigurationFileDirectory, "conf_dir", "directory with toml configuration files")
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Reference in New Issue
Block a user