@@ -45,8 +45,8 @@ pub enum Role {
4545}
4646
4747pub trait StartupVerification {
48- fn stop ( & self ) -> bool ;
49- fn success ( & self ) -> bool ;
48+ fn if_stopped ( & self ) -> bool ;
49+ fn if_succeed ( & self ) -> bool ;
5050}
5151
5252#[ derive( Clone , Debug ) ]
@@ -61,12 +61,12 @@ impl RestStartupVerification {
6161}
6262
6363impl StartupVerification for RestStartupVerification {
64- fn stop ( & self ) -> bool {
64+ fn if_stopped ( & self ) -> bool {
6565 let logger = JormungandrLogger :: new ( self . config . log_file_path . clone ( ) ) ;
6666 logger. contains_error ( ) . unwrap_or_else ( |_| false )
6767 }
6868
69- fn success ( & self ) -> bool {
69+ fn if_succeed ( & self ) -> bool {
7070 let output = process_utils:: run_process_and_get_output (
7171 jcli_commands:: get_rest_stats_command ( & self . config . get_node_address ( ) ) ,
7272 ) ;
@@ -100,15 +100,15 @@ impl LogStartupVerification {
100100}
101101
102102impl StartupVerification for LogStartupVerification {
103- fn stop ( & self ) -> bool {
103+ fn if_stopped ( & self ) -> bool {
104104 let logger = JormungandrLogger :: new ( self . config . log_file_path . clone ( ) ) ;
105105 logger. contains_error ( ) . unwrap_or_else ( |_| false )
106106 }
107107
108- fn success ( & self ) -> bool {
108+ fn if_succeed ( & self ) -> bool {
109109 let logger = JormungandrLogger :: new ( self . config . log_file_path . clone ( ) ) ;
110110 logger
111- . message_logged_multiple_times ( "initial bootstrap completed" , 2 )
111+ . contains_message ( "genesis block fetched" )
112112 . unwrap_or_else ( |_| false )
113113 }
114114}
@@ -212,23 +212,25 @@ impl Starter {
212212 process_assert:: assert_process_failed_and_matches_message ( command, & expected_msg) ;
213213 }
214214
215- fn success ( & self ) -> bool {
215+ fn if_succeed ( & self ) -> bool {
216216 match self . verification_mode {
217217 StartupVerificationMode :: Rest => {
218- RestStartupVerification :: new ( self . config . clone ( ) ) . success ( )
218+ RestStartupVerification :: new ( self . config . clone ( ) ) . if_succeed ( )
219219 }
220220 StartupVerificationMode :: Log => {
221- LogStartupVerification :: new ( self . config . clone ( ) ) . success ( )
221+ LogStartupVerification :: new ( self . config . clone ( ) ) . if_succeed ( )
222222 }
223223 }
224224 }
225225
226- fn stop ( & self ) -> bool {
226+ fn if_stopped ( & self ) -> bool {
227227 match self . verification_mode {
228228 StartupVerificationMode :: Rest => {
229- RestStartupVerification :: new ( self . config . clone ( ) ) . stop ( )
229+ RestStartupVerification :: new ( self . config . clone ( ) ) . if_stopped ( )
230+ }
231+ StartupVerificationMode :: Log => {
232+ LogStartupVerification :: new ( self . config . clone ( ) ) . if_stopped ( )
230233 }
231- StartupVerificationMode :: Log => LogStartupVerification :: new ( self . config . clone ( ) ) . stop ( ) ,
232234 }
233235 }
234236
@@ -254,19 +256,21 @@ impl Starter {
254256 log_content : file_utils:: read_file ( & self . config . log_file_path ) ,
255257 } ) ;
256258 }
257- if self . success ( ) {
259+ if self . if_succeed ( ) {
260+ println ! ( "jormungandr is up" ) ;
258261 return Ok ( JormungandrProcess :: from_config (
259262 process,
260263 self . config . clone ( ) ,
261264 ) ) ;
262265 }
263- if self . stop ( ) {
266+ self . custom_errors_found ( ) ?;
267+ if self . if_stopped ( ) {
268+ println ! ( "attempt stopped due to error signal recieved" ) ;
264269 logger. print_raw_log ( ) ;
265270 return Err ( StartupError :: ErrorInLogsFound {
266271 log_content : file_utils:: read_file ( & self . config . log_file_path ) ,
267272 } ) ;
268273 }
269- self . custom_errors_found ( ) ?;
270274 process_utils:: sleep ( self . sleep ) ;
271275 }
272276 }
0 commit comments