Skip to content

Commit

Permalink
feat: pass config file via command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
archidoge0 committed Apr 24, 2024
1 parent c3c41a7 commit 3ac3a54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type RuntimeArguments struct {
EnableTest bool
TestBlockHeightLimit uint
EnablePprof bool
ConfigFilePath string
}

func NewRuntimeArguments() *RuntimeArguments {
Expand Down Expand Up @@ -50,15 +51,18 @@ leveraging Bitcoin's immutable and decentralized nature to provide a Turing-comp
log.Printf("Use the test mode and limit the max blockheight %d to avoid catching up to the real latest block.\n", arguments.TestBlockHeightLimit)
}

log.Printf("The path of the config file is %s\n", arguments.ConfigFilePath)

Execution(arguments)
},
}

rootCmd.Flags().BoolVarP(&arguments.EnableService, "service", "s", false, "Enable this flag to provide API service")
rootCmd.Flags().BoolVarP(&arguments.EnableCommittee, "committee", "", false, "Enable this flag to provide committee service by uploading checkpoint")
rootCmd.Flags().BoolVarP(&arguments.EnableStateRootCache, "cache", "", true, "Enable this flag to cache State Root")
rootCmd.Flags().BoolVar(&arguments.EnableCommittee, "committee", false, "Enable this flag to provide committee service by uploading checkpoint")
rootCmd.Flags().BoolVar(&arguments.EnableStateRootCache, "cache", true, "Enable this flag to cache State Root")
rootCmd.Flags().BoolVarP(&arguments.EnableTest, "test", "t", false, "Enable this flag to hijack the blockheight to test the service")
rootCmd.Flags().UintVarP(&arguments.TestBlockHeightLimit, "blockheight", "", 0, "When -test enabled, you can set TestBlockHeightLimit as a fixed value you want.")
rootCmd.Flags().UintVar(&arguments.TestBlockHeightLimit, "blockheight", 0, "When -test enabled, you can set TestBlockHeightLimit as a fixed value you want.")
rootCmd.Flags().BoolVar(&arguments.EnablePprof, "pprof", false, "Enable the pprof HTTP handler (at `/debug/pprof/`)")
rootCmd.Flags().StringVar(&arguments.ConfigFilePath, "cfg", "config.json", "Indicate the path of config.json")
return rootCmd
}
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ func ServiceStage(ordGetter getter.OrdGetter, arguments *RuntimeArguments, queue
func Execution(arguments *RuntimeArguments) {

// TODO: High. Get the version from Git Tag.
Version = "v0.1.0-rc.3"
Version = "v0.1.0"

// Get the configuration.
configFile, err := os.ReadFile("config.json")
configFile, err := os.ReadFile(arguments.ConfigFilePath)
if err != nil {
log.Fatalf("Failed to read config file: %v", err)
}
Expand Down

0 comments on commit 3ac3a54

Please sign in to comment.