Skip to content

Commit

Permalink
Merge pull request #6 from anoma/fraccaman/minors
Browse files Browse the repository at this point in the history
run migrations
  • Loading branch information
sug0 committed Jul 5, 2024
2 parents d00e474 + 8c8d2ef commit 20649ae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
12 changes: 12 additions & 0 deletions chain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::collections::BTreeMap;
use std::sync::atomic::{self, AtomicBool};
use std::sync::Arc;

use anyhow::Context;
use clap::Parser;
use shared::error::{IntoMainError, MainError};
use shared::height::{BlockHeight, FollowingHeights};
Expand Down Expand Up @@ -46,6 +47,8 @@ async fn main() -> Result<(), MainError> {

let app_state = AppState::new(database_url).into_db_error()?;

run_migrations(&app_state).await?;

let (last_block_height, commitment_tree, witness_map) =
load_committed_state(&app_state).await?;

Expand Down Expand Up @@ -102,6 +105,15 @@ fn must_exit_handle() -> Arc<AtomicBool> {
handle
}

async fn run_migrations(app_state: &AppState) -> Result<(), MainError> {
db_service::run_migrations(
app_state.get_db_connection().await.into_db_error()?,
)
.await
.context("Failed to run db migrations")
.into_db_error()
}

async fn load_committed_state(
app_state: &AppState,
) -> Result<(Option<BlockHeight>, CommitmentTree, WitnessMap), MainError> {
Expand Down
14 changes: 5 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ services:
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
PGUSER: postgres
POSTGRES_DB: indexer_local
POSTGRES_DB: masp_indexer_local
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-d", "indexer_local"]
test: ["CMD-SHELL", "pg_isready", "-d", "masp_indexer_local"]
interval: 5s
timeout: 10s
retries: 5
Expand All @@ -24,23 +24,19 @@ services:
ports:
- 5000:5000
environment:
CARGO_ENV: development
PORT: 5000
DATABASE_URL: postgres://postgres:password@postgres:5432/indexer_local
DATABASE_URL: postgres://postgres:password@postgres:5432/masp_indexer_local
depends_on:
- crawler

crawler:
image: namada-masp-crawler
build:
context: .
dockerfile: chain/Dockerfile
environment:
CARGO_ENV: development
TENDERMINT_URL: <>
CHECKSUMS_FILEPATH: <>
COMETBFT_URL: <>
CHAIN_ID: <>
DATABASE_URL: postgres://postgres:password@postgres:5432/indexer_local
DATABASE_URL: postgres://postgres:password@postgres:5432/masp_indexer_local
depends_on:
postgres:
condition: service_healthy
Expand Down
1 change: 1 addition & 0 deletions webserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition.workspace = true
license.workspace = true
readme.workspace = true
version.workspace = true
build = "build.rs"

[[bin]]
name = "webserver"
Expand Down

0 comments on commit 20649ae

Please sign in to comment.