mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-02 11:43:40 +02:00
cmd/thalos/server.go: use the new config.Builder
This commit is contained in:
parent
0d1bec6a62
commit
cad74a4d84
1 changed files with 10 additions and 17 deletions
|
|
@ -153,7 +153,7 @@ func initAbiManager(api *eos.API, store cache.Store, chain_id string) *abi.AbiMa
|
||||||
return abi.NewAbiManager(cache, api)
|
return abi.NewAbiManager(cache, api)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stateLoader(conf config.Config, chainInfo *eos.InfoResp, cache *cache.Cache, current_block_no_cache bool) StateLoader {
|
func stateLoader(conf *config.Config, chainInfo *eos.InfoResp, cache *cache.Cache, current_block_no_cache bool) StateLoader {
|
||||||
return func(state *State) {
|
return func(state *State) {
|
||||||
var source string
|
var source string
|
||||||
|
|
||||||
|
|
@ -198,23 +198,16 @@ func stateSaver(cache *cache.Cache) StateSaver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadConfig(cfg *config.Config, flags *pflag.FlagSet) error {
|
func GetConfig(flags *pflag.FlagSet) (*config.Config, error) {
|
||||||
filename, err := flags.GetString("config")
|
filename, err := flags.GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read file first.
|
return config.NewBuilder().
|
||||||
if err := cfg.ReadFile(filename); err != nil {
|
SetConfigFile(filename).
|
||||||
return err
|
SetFlags(flags).
|
||||||
}
|
Build()
|
||||||
|
|
||||||
// Then override any cli flags
|
|
||||||
if err := cfg.ReadCliFlags(flags); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func serverCmd(cmd *cobra.Command, args []string) {
|
func serverCmd(cmd *cobra.Command, args []string) {
|
||||||
|
|
@ -234,8 +227,8 @@ func serverCmd(cmd *cobra.Command, args []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse config
|
// Parse config
|
||||||
conf := config.New()
|
conf, err := GetConfig(cmd.Flags())
|
||||||
if err = ReadConfig(&conf, cmd.Flags()); err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Fatal("Failed to read config")
|
log.WithError(err).Fatal("Failed to read config")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -354,7 +347,7 @@ func serverCmd(cmd *cobra.Command, args []string) {
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run the application
|
// Run the application
|
||||||
run(&conf, shClient, processor)
|
run(conf, shClient, processor)
|
||||||
|
|
||||||
// Close the processor properly
|
// Close the processor properly
|
||||||
processor.Close()
|
processor.Close()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue