Skip to content

Commit

Permalink
Enhancement: run script and readme updates (#84)
Browse files Browse the repository at this point in the history
* [README/run] Update the run.sh scripts and README to allow configuration in one single .env file

* [justfile] add run-* commands

* Remove references to CHAIN_ID
  • Loading branch information
joel-u410 authored Jul 25, 2024
1 parent ff40594 commit 7a2a2dd
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 18 deletions.
1 change: 0 additions & 1 deletion .env_sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
DATABASE_URL=postgres://postgres:password@postgres:5432/namada-indexer
TENDERMINT_URL=http://host.docker.internal:27657
CHAIN_ID=local.82f9d1c42fdcadbb287ce393
CACHE_URL=redis://dragonfly:6379
WEBSERVER_PORT=5000
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ cp .env_sample .env
- Get a Namada RPC url
- [Either create a local chain ](https://github.com/anoma/namada/blob/main/scripts/gen_localnet.py)
- Or use a Public RPC
- Change `CHAIN_ID`
- Install [just](https://github.com/casey/just)
- Run `just docker-run`

Expand All @@ -41,7 +40,18 @@ cp .env_sample .env
- Get a Namada RPC url
- [Either create a local chain ](https://github.com/anoma/namada/blob/main/scripts/gen_localnet.py)
- Or use a Public RPC
- Get a network `CHAIN_ID`
- Create a `.env` file in the root of the project with the following content:
```env
DATABASE_URL=postgres://postgres:[email protected]:5435/namada-indexer
TENDERMINT_URL=http://127.0.0.1:27657
```
(Change the values to match your setup)
- For `webserver` only, you may also add the following to the `.env` file:
```env
CACHE_URL=redis://[email protected]:6379
PORT=5000
```
(Change the values to match your setup)
- Use the `run.sh` script inside each package. Keep in mind that PoS package have to be run always while other service might not

## Testing via seeder
Expand Down
5 changes: 4 additions & 1 deletion chain/run.sh
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
cargo run -- --tendermint-url http://127.0.0.1:27657 --initial-query-retry-time 5 --database-url postgres://postgres:[email protected]:5435/namada-indexer
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run -- --initial-query-retry-time 5
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ x-defaults: &defaults
args: &build-args
DATABASE_URL: ${DATABASE_URL}
TENDERMINT_URL: ${TENDERMINT_URL}
CHAIN_ID: ${CHAIN_ID}
CACHE_URL: ${CACHE_URL}
WEBSERVER_PORT: ${WEBSERVER_PORT}
environment: &env-vars
Expand Down
6 changes: 4 additions & 2 deletions governance/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

cargo run -- --tendermint-url http://127.0.0.1:27657 --database-url postgres://postgres:[email protected]:5435/namada-indexer --sleep-for 15
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run -- --sleep-for 15
26 changes: 25 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,28 @@ docker-up:
docker compose up

clean:
cargo clean
cargo clean

run-chain:
(cd chain && ./run.sh)

run-governance:
(cd governance && ./run.sh)

run-parameters:
(cd parameters && ./run.sh)

run-pos:
(cd pos && ./run.sh)

run-rewards:
(cd rewards && ./run.sh)

run-seeder:
(cd seeder && ./run.sh)

run-transactions:
(cd transactions && ./run.sh)

run-webserver:
(cd webserver && ./run.sh)
6 changes: 4 additions & 2 deletions parameters/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

cargo run -- --tendermint-url http://127.0.0.1:27657 --database-url postgres://postgres:[email protected]:5435/namada-indexer --sleep-for 15
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run -- --sleep-for 15
6 changes: 4 additions & 2 deletions pos/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

cargo run -- --tendermint-url http://127.0.0.1:27657 --database-url postgres://postgres:[email protected]:5435/namada-indexer
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run
6 changes: 4 additions & 2 deletions rewards/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

cargo run -- --tendermint-url http://127.0.0.1:27657 --database-url postgres://postgres:[email protected]:5435/namada-indexer --sleep-for 15
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run -- --sleep-for 15
6 changes: 4 additions & 2 deletions seeder/run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

cargo run -- --cargo-env development --tendermint-url http://127.0.0.1:27657 --database-url postgres://postgres:[email protected]:5435/indexer_local
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run -- --cargo-env development
5 changes: 4 additions & 1 deletion transactions/run.sh
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
cargo run -- --database-url postgres://postgres:[email protected]:5435/namada-indexer --tendermint-url http://127.0.0.1:27657
. ../.env
export TENDERMINT_URL
export DATABASE_URL
cargo run
7 changes: 6 additions & 1 deletion webserver/run.sh
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
cargo run -- --database-url postgres://postgres:[email protected]:5435/namada-indexer --cache-url redis://[email protected]:6379 --tendermint-url http://127.0.0.1:27657
. ../.env
export TENDERMINT_URL
export DATABASE_URL
export CACHE_URL
export PORT
cargo run

0 comments on commit 7a2a2dd

Please sign in to comment.