File tree Expand file tree Collapse file tree
src/programs/core/ignition Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,6 +201,9 @@ export default {
201201 // start initial services
202202 svc_mgr . start_initial_services ( ) ;
203203
204+ let window_start : number | null = null ;
205+ let deaths_in_window = 0 ;
206+
204207 // execute boot target in a respawn loop
205208 while ( running ) {
206209 const boot_target_proc = kernel . spawn ( boot_target , boot_args ) ;
@@ -219,7 +222,28 @@ export default {
219222
220223 console . log ( `boot target ${ boot_target } exited with code ${ exit_code } ` ) ;
221224
222- // TODO: error recovery logic if boot target fails multiple times in a row
225+ term . writeln ( `Boot target ${ boot_target } exited with code ${ exit_code } !` ) ;
226+ if ( error ) {
227+ term . writeln ( `Error details: ${ error } ` ) ;
228+ }
229+
230+ const now = Date . now ( ) ;
231+ if ( ! window_start || ( now - window_start ) > 10000 ) {
232+ window_start = now ;
233+ deaths_in_window = 0 ;
234+ }
235+
236+ deaths_in_window ++ ;
237+
238+ if ( deaths_in_window >= 5 ) {
239+ term . writeln ( "Boot target has crashed too many times in a short period. Halting to prevent a crash loop." ) ;
240+ term . writeln ( "Press any key to retry..." ) ;
241+ await term . wait_for_keypress ( ) ;
242+ deaths_in_window = 0 ;
243+ window_start = null ;
244+ }
245+
246+ // TODO: add recovery options
223247 }
224248
225249 return final_code ;
You can’t perform that action at this time.
0 commit comments