Skip to content

Commit

Permalink
Developer Tools: create indexer data dir (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiqizng authored May 9, 2022
1 parent 457adcf commit 58e68aa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/algorand-indexer/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (
maxApplicationsLimit uint32
defaultApplicationsLimit uint32
enableAllParameters bool
indexerDataDir string
)

var daemonCmd = &cobra.Command{
Expand Down Expand Up @@ -75,6 +76,17 @@ var daemonCmd = &cobra.Command{
algodDataDir = os.Getenv("ALGORAND_DATA")
}

if indexerDataDir == "" {
indexerDataDir = os.Getenv("INDEXER_DATA")
}

if indexerDataDir != "" {
if _, err := os.Stat(indexerDataDir); os.IsNotExist(err) {
err := os.Mkdir(indexerDataDir, 0755)
maybeFail(err, "indexer data directory error, %v", err)
}
}

ctx, cf := context.WithCancel(context.Background())
defer cf()
{
Expand Down Expand Up @@ -185,6 +197,8 @@ func init() {
daemonCmd.Flags().Uint32VarP(&maxApplicationsLimit, "max-applications-limit", "", 1000, "set the maximum allowed Limit parameter for querying applications")
daemonCmd.Flags().Uint32VarP(&defaultApplicationsLimit, "default-applications-limit", "", 100, "set the default Limit parameter for querying applications, if none is provided")

daemonCmd.Flags().StringVarP(&indexerDataDir, "data-dir", "i", "", "path to indexer data dir, or $INDEXER_DATA")

viper.RegisterAlias("algod", "algod-data-dir")
viper.RegisterAlias("algod-net", "algod-address")
viper.RegisterAlias("server", "server-address")
Expand Down

0 comments on commit 58e68aa

Please sign in to comment.