11use aptos_indexer_processor_sdk:: server_framework:: RunnableConfig ;
2+ use godfig:: { backend:: config_file:: ConfigFile , Godfig } ;
23use maptos_execution_util:: config:: Config ;
34use movement_health:: run_service;
45use movement_tracing:: simple_metrics:: start_metrics_server;
@@ -10,27 +11,37 @@ fn main() -> Result<(), anyhow::Error> {
1011 init_logger ( ) ;
1112
1213 let runtime = get_maptos_runtime ( ) ;
13- let maptos_config = load_maptos_config ( ) ?;
14- let runnable_processor_config: IndexerProcessorConfig =
15- maptos_config. indexer_processor_v2 . clone ( ) . into ( ) ;
1614
1715 runtime. block_on ( async move {
16+ let maptos_config = load_maptos_config ( ) . await . expect ( "Failed to load maptos config" ) ;
17+ let runnable_processor_config: IndexerProcessorConfig =
18+ maptos_config. indexer_processor_v2 . clone ( ) . into ( ) ;
19+
1820 let metrics_handle = tokio:: spawn ( async move {
19- start_metrics_server (
21+ let res = start_metrics_server (
2022 maptos_config. indexer_processor_v2 . metrics_config . listen_hostname ,
2123 maptos_config. indexer_processor_v2 . metrics_config . listen_port ,
2224 )
23- . await
25+ . await ;
26+ tracing:: info!( "Metrics server started: {:?}" , res) ;
27+ res
2428 } ) ;
2529 let health_handle = tokio:: spawn ( async move {
26- run_service (
30+ let res = run_service (
2731 maptos_config. indexer_processor_v2 . health_config . hostname ,
2832 maptos_config. indexer_processor_v2 . health_config . port ,
2933 )
30- . await
34+ . await ;
35+ tracing:: info!( "Health server started: {:?}" , res) ;
36+ res
3137 } ) ;
3238
33- let processor_handle = tokio:: spawn ( async move { runnable_processor_config. run ( ) . await } ) ;
39+ let processor_handle = tokio:: spawn ( async move {
40+ let res = runnable_processor_config. run ( ) . await ;
41+ tracing:: info!( "Indexer processor started: {:?}" , res) ;
42+ res
43+ } ) ;
44+ tracing:: info!( "Indexer v2 stack started." ) ;
3445
3546 tokio:: select! {
3647 metrics_handle = metrics_handle => {
@@ -43,6 +54,7 @@ fn main() -> Result<(), anyhow::Error> {
4354 tracing:: error!( "Indexer processor exited abnormally: {:?}" , processor_handle) ;
4455 }
4556 }
57+ tracing:: info!( "Indexer v2 stack exited normally." ) ;
4658 } ) ;
4759 panic ! ( "Indexer v2 stack exited abnormally." ) ;
4860}
@@ -78,8 +90,17 @@ fn get_maptos_runtime() -> tokio::runtime::Runtime {
7890 runtime
7991}
8092
81- fn load_maptos_config ( ) -> anyhow:: Result < Config > {
93+ async fn load_maptos_config ( ) -> anyhow:: Result < Config > {
94+ // get the config file
8295 let dot_movement = dot_movement:: DotMovement :: try_from_env ( ) ?;
83- let maptos_config = dot_movement. try_get_config_from_json :: < Config > ( ) ?;
96+
97+ // Load Maptos config
98+ let maptos_config = {
99+ let config_file = dot_movement. try_get_or_create_config_file ( ) . await ?;
100+ let godfig: Godfig < maptos_execution_util:: config:: Config , ConfigFile > =
101+ Godfig :: new ( ConfigFile :: new ( config_file) , vec ! [ "maptos_config" . to_string( ) ] ) ;
102+ godfig. try_wait_for_ready ( ) . await
103+ } ?;
104+
84105 Ok ( maptos_config)
85106}
0 commit comments