@@ -45,8 +45,8 @@ pub enum Role {
45
45
}
46
46
47
47
pub trait StartupVerification {
48
- fn stop ( & self ) -> bool ;
49
- fn success ( & self ) -> bool ;
48
+ fn if_stopped ( & self ) -> bool ;
49
+ fn if_succeed ( & self ) -> bool ;
50
50
}
51
51
52
52
#[ derive( Clone , Debug ) ]
@@ -61,12 +61,12 @@ impl RestStartupVerification {
61
61
}
62
62
63
63
impl StartupVerification for RestStartupVerification {
64
- fn stop ( & self ) -> bool {
64
+ fn if_stopped ( & self ) -> bool {
65
65
let logger = JormungandrLogger :: new ( self . config . log_file_path . clone ( ) ) ;
66
66
logger. contains_error ( ) . unwrap_or_else ( |_| false )
67
67
}
68
68
69
- fn success ( & self ) -> bool {
69
+ fn if_succeed ( & self ) -> bool {
70
70
let output = process_utils:: run_process_and_get_output (
71
71
jcli_commands:: get_rest_stats_command ( & self . config . get_node_address ( ) ) ,
72
72
) ;
@@ -100,15 +100,15 @@ impl LogStartupVerification {
100
100
}
101
101
102
102
impl StartupVerification for LogStartupVerification {
103
- fn stop ( & self ) -> bool {
103
+ fn if_stopped ( & self ) -> bool {
104
104
let logger = JormungandrLogger :: new ( self . config . log_file_path . clone ( ) ) ;
105
105
logger. contains_error ( ) . unwrap_or_else ( |_| false )
106
106
}
107
107
108
- fn success ( & self ) -> bool {
108
+ fn if_succeed ( & self ) -> bool {
109
109
let logger = JormungandrLogger :: new ( self . config . log_file_path . clone ( ) ) ;
110
110
logger
111
- . message_logged_multiple_times ( "initial bootstrap completed" , 2 )
111
+ . contains_message ( "genesis block fetched" )
112
112
. unwrap_or_else ( |_| false )
113
113
}
114
114
}
@@ -212,23 +212,25 @@ impl Starter {
212
212
process_assert:: assert_process_failed_and_matches_message ( command, & expected_msg) ;
213
213
}
214
214
215
- fn success ( & self ) -> bool {
215
+ fn if_succeed ( & self ) -> bool {
216
216
match self . verification_mode {
217
217
StartupVerificationMode :: Rest => {
218
- RestStartupVerification :: new ( self . config . clone ( ) ) . success ( )
218
+ RestStartupVerification :: new ( self . config . clone ( ) ) . if_succeed ( )
219
219
}
220
220
StartupVerificationMode :: Log => {
221
- LogStartupVerification :: new ( self . config . clone ( ) ) . success ( )
221
+ LogStartupVerification :: new ( self . config . clone ( ) ) . if_succeed ( )
222
222
}
223
223
}
224
224
}
225
225
226
- fn stop ( & self ) -> bool {
226
+ fn if_stopped ( & self ) -> bool {
227
227
match self . verification_mode {
228
228
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 ( )
230
233
}
231
- StartupVerificationMode :: Log => LogStartupVerification :: new ( self . config . clone ( ) ) . stop ( ) ,
232
234
}
233
235
}
234
236
@@ -254,19 +256,21 @@ impl Starter {
254
256
log_content : file_utils:: read_file ( & self . config . log_file_path ) ,
255
257
} ) ;
256
258
}
257
- if self . success ( ) {
259
+ if self . if_succeed ( ) {
260
+ println ! ( "jormungandr is up" ) ;
258
261
return Ok ( JormungandrProcess :: from_config (
259
262
process,
260
263
self . config . clone ( ) ,
261
264
) ) ;
262
265
}
263
- if self . stop ( ) {
266
+ self . custom_errors_found ( ) ?;
267
+ if self . if_stopped ( ) {
268
+ println ! ( "attempt stopped due to error signal recieved" ) ;
264
269
logger. print_raw_log ( ) ;
265
270
return Err ( StartupError :: ErrorInLogsFound {
266
271
log_content : file_utils:: read_file ( & self . config . log_file_path ) ,
267
272
} ) ;
268
273
}
269
- self . custom_errors_found ( ) ?;
270
274
process_utils:: sleep ( self . sleep ) ;
271
275
}
272
276
}
0 commit comments