diff --git a/nft_ingester/src/bin/ingester/main.rs b/nft_ingester/src/bin/ingester/main.rs index ae829a7b..0acf0496 100644 --- a/nft_ingester/src/bin/ingester/main.rs +++ b/nft_ingester/src/bin/ingester/main.rs @@ -84,12 +84,12 @@ pub async fn main() -> Result<(), IngesterError> { info!("Starting Ingester..."); info!("___________________________________",); - info!("API: {}", args.run_api); - if args.run_api { + info!("API: {}", args.run_api.unwrap_or(false)); + if args.run_api.unwrap_or(false) { info!("API port: localhost:{}", args.server_port); } - info!("Back Filler: {}", args.run_backfiller); - info!("Bubblegum BackFiller: {}", args.run_bubblegum_backfiller); + info!("Back Filler: {}", args.run_backfiller.unwrap_or(false)); + info!("Bubblegum BackFiller: {}", args.run_bubblegum_backfiller.unwrap_or(false)); info!("Gap Filler: {}", args.run_gapfiller); info!("Run Profiling: {}", args.run_profiling); info!("Sequence Consistent Checker: {}", args.run_sequence_consistent_checker); @@ -134,7 +134,7 @@ pub async fn main() -> Result<(), IngesterError> { let primary_rocks_storage = Arc::new( init_primary_storage( &args.rocks_db_path_container, - args.enable_rocks_migration, + args.enable_rocks_migration.unwrap_or(false), &args.rocks_migration_storage_path, &metrics_state, mutexed_tasks.clone(), @@ -331,7 +331,7 @@ pub async fn main() -> Result<(), IngesterError> { let cloned_rx = shutdown_rx.resubscribe(); let file_storage_path = args.file_storage_path_container.clone(); - if args.run_api { + if args.run_api.unwrap_or(false) { info!("Starting API (Ingester)..."); let middleware_json_downloader = args .json_middleware_config @@ -394,7 +394,7 @@ pub async fn main() -> Result<(), IngesterError> { let shutdown_token = CancellationToken::new(); // Backfiller - if args.run_backfiller { + if args.run_backfiller.unwrap_or(false) { info!("Start backfiller..."); let backfill_bubblegum_updates_processor = Arc::new(BubblegumTxProcessor::new( @@ -429,7 +429,7 @@ pub async fn main() -> Result<(), IngesterError> { .await, ); - if args.run_bubblegum_backfiller { + if args.run_bubblegum_backfiller.unwrap_or(false) { info!("Runing Bubblegum backfiller (ingester)..."); if args.should_reingest { diff --git a/nft_ingester/src/bin/ingester/readme.md b/nft_ingester/src/bin/ingester/readme.md index 11e288c0..d363c821 100644 --- a/nft_ingester/src/bin/ingester/readme.md +++ b/nft_ingester/src/bin/ingester/readme.md @@ -28,9 +28,9 @@ Run indexer with minimum functionality. (without API/Back Filler/Bubblegum BackF --pg-database-url postgres://solana:solana@localhost:5432/aura_db \ --rpc-host https://mainnet-aura.metaplex.com/{personal_rpc_key} \ --redis-connection-config '{"redis_connection_str":"redis://127.0.0.1:6379/0"}' \ - --disable-api \ - --disable-backfiller \ - --disable-rocks-migration + --run-api false \ + --run-backfiller false \ + --enable-rocks-migration false ``` diff --git a/nft_ingester/src/config.rs b/nft_ingester/src/config.rs index 02d22a1d..ed0ad406 100644 --- a/nft_ingester/src/config.rs +++ b/nft_ingester/src/config.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use clap::{ArgAction, Parser, ValueEnum}; +use clap::{Parser, ValueEnum}; // TODO: replace String paths with PathBuf use figment::value::Dict; use serde::Deserialize; @@ -71,13 +71,12 @@ pub struct IngesterClapArgs { pub parallel_json_downloaders: i32, #[clap( - long("disable-api"), - default_value_t = true, - action = ArgAction::SetFalse, + long("run-api"), + default_value = "true", env = "RUN_API", - help = "Disable API (default: true)" + help = "Run API (default: true)" )] - pub run_api: bool, + pub run_api: Option, #[clap( long("run-gapfiller"), @@ -92,7 +91,7 @@ pub struct IngesterClapArgs { pub gapfiller_peer_addr: Option, #[clap( - long("run-profiling"), + long, default_value_t = false, env = "INGESTER_RUN_PROFILING", help = "Start profiling (default: false)" @@ -117,16 +116,19 @@ pub struct IngesterClapArgs { #[clap(long, env, help = "Rocks backup archives dir")] pub rocks_backup_archives_dir: Option, - // requires = "rocks_migration_storage_path" is not working because default value is true. (clap issue) #[clap( - long("disable-rocks-migration"), + long, env = "ENABLE_ROCKS_MIGRATION", - action = ArgAction::SetFalse, - default_value_t = true, - help = "Disable migration for rocksdb (default: true) requires: rocks_migration_storage_path" + default_value = "true", + help = "Enable migration for rocksdb (default: true) requires: rocks_migration_storage_path" + )] + pub enable_rocks_migration: Option, + #[clap( + long, + env, + requires_if("true", "enable_rocks_migration"), + help = "Migration storage path dir" )] - pub enable_rocks_migration: bool, - #[clap(long, env, help = "Migration storage path dir")] pub rocks_migration_storage_path: Option, #[clap(long, env, help = "Start consistent checker (default: false)")] @@ -184,18 +186,17 @@ pub struct IngesterClapArgs { #[clap(long, env, help = "#api Storage service base url")] pub storage_service_base_url: Option, - // requires = "rocks_slots_db_path" is not working because default value is true. #[clap( - long("disable-backfiller"), - action = ArgAction::SetFalse, + long, env = "RUN_BACKFILLER", - default_value_t = true, - help = "Disable backfiller. (default: true) requires: rocks_slots_db_path", + default_value = "true", + help = "Run backfiller. (default: true) requires: rocks_slots_db_path" )] - pub run_backfiller: bool, + pub run_backfiller: Option, #[clap( long, env, + requires_if("true", "run_backfiller"), help = "#backfiller Path to the RocksDB instance with slots (required for the backfiller to work)" )] pub rocks_slots_db_path: Option, @@ -216,13 +217,12 @@ pub struct IngesterClapArgs { pub big_table_config: Option, #[clap( - long("disable-bubblegum-backfiller"), - action = ArgAction::SetFalse, + long, env = "RUN_BUBBLEGUM_BACKFILLER", - default_value_t = true, - help = "#bubbl Disable bubblegum backfiller (default: true)" + default_value = "true", + help = "#bubbl Run bubblegum backfiller (default: true)" )] - pub run_bubblegum_backfiller: bool, + pub run_bubblegum_backfiller: Option, #[clap( long, env = "SHOULD_REINGEST", @@ -606,18 +606,18 @@ mod tests { assert_eq!(args.pg_max_db_connections, 100); assert_eq!(args.sequence_consistent_checker_wait_period_sec, 60); assert_eq!(args.parallel_json_downloaders, 100); - assert_eq!(args.run_api, true); + assert!(args.run_api.unwrap_or(false)); assert_eq!(args.run_gapfiller, false); assert_eq!(args.run_profiling, false); assert_eq!(args.is_restore_rocks_db, false); - assert_eq!(args.run_bubblegum_backfiller, true); + assert!(args.run_bubblegum_backfiller.unwrap_or(false)); assert_eq!(args.run_sequence_consistent_checker, false); assert_eq!(args.should_reingest, false); assert_eq!(args.check_proofs, false); assert_eq!(args.check_proofs_commitment, CommitmentLevel::Finalized); assert_eq!(args.archives_dir, "/rocksdb/_rocks_backup_archives"); assert_eq!(args.skip_check_tree_gaps, false); - assert_eq!(args.run_backfiller, true); + assert!(args.run_backfiller.unwrap_or(false)); assert_eq!(args.backfiller_source_mode, BackfillerSourceMode::RPC); assert_eq!(args.heap_path, "/usr/src/app/heaps"); assert_eq!(args.log_level, "info");