Skip to content

Commit

Permalink
Localledger merge (#1036)
Browse files Browse the repository at this point in the history
* return empty lists from fetchApplications and fetchAppLocalStates (#1010)

* Update model to converge with algod (#1005)

* New Feature: Adds Data Directory Support (#1012)

- Updates the go-algorand submodule hash to point to rel/beta
- Moves the cpu profiling file, pid file and indexer configuration file
  to be options of only the daemon sub-command
- Changes os.Exit() to be a panic with a special handler.  This is so
  that defer's are handled instead of being ignored.
- Detects auto-loading configuration files in the data directory and
  issues errors if equivalent command line arguments are supplied.
- Updates the README with instructions on how to use the auto-loading
  configuration files and the data directory.

* Update mockery version

Co-authored-by: erer1243 <1377477+erer1243@users.noreply.github.com>
Co-authored-by: AlgoStephenAkiki <85183435+AlgoStephenAkiki@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 16, 2022
1 parent eff4e6f commit 5a56ad2
Show file tree
Hide file tree
Showing 21 changed files with 572 additions and 454 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -34,8 +34,8 @@ idb/postgres/internal/schema/setup_postgres_sql.go: idb/postgres/internal/schema
cd idb/postgres/internal/schema && go generate

idb/mocks/IndexerDb.go: idb/idb.go
go install github.com/vektra/mockery/.../
cd idb && mockery -name=IndexerDb
go install github.com/vektra/mockery/v2@v2.12.3
cd idb && mockery --name=IndexerDb

# check that all packages (except tests) compile
check: go-algorand
Expand Down
57 changes: 33 additions & 24 deletions README.md
Expand Up @@ -195,7 +195,7 @@ Settings can be provided from the command line, a configuration file, or an envi
| default-balances-limit | | default-balances-limit | INDEXER_DEFAULT_BALANCES_LIMIT |
| max-applications-limit | | max-applications-limit | INDEXER_MAX_APPLICATIONS_LIMIT |
| default-applications-limit | | default-applications-limit | INDEXER_DEFAULT_APPLICATIONS_LIMIT |
| data-dir | i | data | INDEXER_DATA |
| data-dir | i | data-dir | INDEXER_DATA |

## Command line

Expand All @@ -205,33 +205,23 @@ The command line arguments always take priority over the config file and environ
~$ ./algorand-indexer daemon --pidfile /var/lib/algorand/algorand-indexer.pid --algod /var/lib/algorand --postgres "host=mydb.mycloud.com user=postgres password=password dbname=mainnet"`
```

## Configuration file
Default values are placed in the configuration file. They can be overridden with environment variables and command line arguments.
## Data Directory

The configuration file must named **indexer**, **indexer.yml**, or **indexer.yaml**. The filepath may be set on the CLI using `--configfile` or `-c`.
When the filepath is not provided on the CLI, it must also be in the correct location. Only one configuration file is loaded, the path is searched in the following order:
* `./` (current working directory)
* `$HOME`
* `$HOME/.algorand-indexer`
* `$HOME/.config/algorand-indexer`
* `/etc/algorand-indexer/`
The Indexer data directory is the location where the Indexer can store and/or load data needed for runtime operation and configuration.

Here is an example **indexer.yml** file:
```
postgres-connection-string: "host=mydb.mycloud.com user=postgres password=password dbname=mainnet"
pidfile: "/var/lib/algorand/algorand-indexer.pid"
algod-data-dir: "/var/lib/algorand"
```
**It is a required argument for Indexer daemon operation. Supply it to the Indexer via the `--data-dir` flag.**

If it is in the current working directory along with the indexer command we can start the indexer daemon with:
```
~$ ./algorand-indexer daemon
```

If it is not in the current working directory along with the indexer command we can start the indexer daemon with:
```
~$ ./algorand-indexer daemon -c <full-file-location>/indexer.yml
```
### Auto-Loading Configuration

The Indexer will scan the data directory at startup and load certain configuration files if they are present. The files are as follows:

- `indexer.yml` - Indexer Configuration File
- `api_config.yml` - API Parameter Enable/Disable Configuration File
-
**NOTE:** It is not allowed to supply both the command line flag AND have an auto-loading configuration file in the data directory. Doing so will result in an error.

To see an example of how to use the data directory to load a configuration file check out the [Disabling Parameters Guide](docs/DisablingParametersGuide.md).

## Example environment variable

Expand All @@ -245,6 +235,25 @@ The same indexer configuration from earlier can be made in bash with the followi
~$ ./algorand-indexer daemon
```


## Configuration file
Default values are placed in the configuration file. They can be overridden with environment variables and command line arguments.

The configuration file must named **indexer.yml** and placed in the data directory (see above). The filepath may be set on the CLI using `--configfile` or `-c` but this functionality is deprecated.

Here is an example **indexer.yml** file:
```
postgres-connection-string: "host=mydb.mycloud.com user=postgres password=password dbname=mainnet"
pidfile: "/var/lib/algorand/algorand-indexer.pid"
algod-data-dir: "/var/lib/algorand"
```

Place this file in the data directory (`/tmp/data-dir` in this example) and supply it to the Indexer daemon:
```
~$ ./algorand-indexer daemon --data-dir /tmp/data-dir
```


# Systemd

`/lib/systemd/system/algorand-indexer.service` can be partially overridden by creating `/etc/systemd/system/algorand-indexer.service.d/local.conf`. The most common things to override will be the command line and pidfile. The overriding local.conf file might be this:
Expand Down

0 comments on commit 5a56ad2

Please sign in to comment.