From e64ffb3deca40f8b3e827244c3af5e5322358476 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Wed, 10 Jul 2024 18:39:39 +0800 Subject: [PATCH] fix: config issue --- backend/conf/config.yml | 30 ++++++++++++++++++++++++--- core/config/config.go | 13 ++++-------- core/config/default_config.go | 39 ----------------------------------- 3 files changed, 31 insertions(+), 51 deletions(-) delete mode 100644 core/config/default_config.go diff --git a/backend/conf/config.yml b/backend/conf/config.yml index 322ade50..dbcfed87 100755 --- a/backend/conf/config.yml +++ b/backend/conf/config.yml @@ -1,3 +1,27 @@ -info: - edition: global.edition.community - version: v0.6.3 +# Crawlab Configuration File +edition: global.edition.community +version: v0.6.3 + +mongo: + host: localhost + port: 27017 + db: crawlab_test + username: "" + password: "" + authSource: "admin" + +server: + host: 0.0.0.0 + port: 8000 + +grpc: + address: localhost:9666 + server: + address: 0.0.0.0:9666 + authKey: Crawlab2021! + +api: + endpoint: http://localhost:8000 + +log: + path: /var/log/crawlab diff --git a/core/config/config.go b/core/config/config.go index 1caa14d7..1eace82a 100644 --- a/core/config/config.go +++ b/core/config/config.go @@ -1,7 +1,6 @@ package config import ( - "bytes" "github.com/apex/log" "github.com/crawlab-team/crawlab/trace" "github.com/fsnotify/fsnotify" @@ -63,14 +62,10 @@ func (c *Config) Init() (err error) { replacer := strings.NewReplacer(".", "_") viper.SetEnvKeyReplacer(replacer) - // read default config - defaultConfBuf := bytes.NewBufferString(DefaultConfigYaml) - if err := viper.ReadConfig(defaultConfBuf); err != nil { - return trace.TraceError(err) - } - - // merge config - if err := viper.MergeInConfig(); err != nil { // viper parsing config file + // read in config + if err := viper.ReadInConfig(); err != nil { + log.Errorf("Error reading config file, %s", err) + trace.PrintError(err) return err } diff --git a/core/config/default_config.go b/core/config/default_config.go deleted file mode 100644 index e2806e67..00000000 --- a/core/config/default_config.go +++ /dev/null @@ -1,39 +0,0 @@ -package config - -var DefaultConfigYaml = ` -version: v0.6.3 -edition: global.edition.community -mongo: - host: localhost - port: 27017 - db: crawlab_test - username: "" - password: "" - authSource: "admin" -server: - host: 0.0.0.0 - port: 8000 -spider: - fs: "/spiders" - workspace: "/workspace" - repo: "/repo" -task: - workers: 16 - cancelWaitSeconds: 30 -grpc: - address: localhost:9666 - server: - address: 0.0.0.0:9666 - authKey: Crawlab2021! -fs: - filer: - proxy: http://localhost:8888 - url: http://localhost:8000/filer - authKey: Crawlab2021! -node: - master: Y -api: - endpoint: http://localhost:8000 -log: - path: /var/log/crawlab -`