@@ -262,7 +262,8 @@ def trinity_boot(args: Namespace,
262
262
networking_process ,
263
263
plugin_manager ,
264
264
main_endpoint ,
265
- event_bus
265
+ event_bus ,
266
+ ev .reason
266
267
)
267
268
)
268
269
@@ -279,7 +280,8 @@ def trinity_boot(args: Namespace,
279
280
networking_process ,
280
281
plugin_manager ,
281
282
main_endpoint ,
282
- event_bus
283
+ event_bus ,
284
+ reason = "CTRL+C / Keyboard Interrupt"
283
285
)
284
286
285
287
@@ -289,7 +291,7 @@ def kill_trinity_gracefully(logger: logging.Logger,
289
291
plugin_manager : PluginManager ,
290
292
main_endpoint : Endpoint ,
291
293
event_bus : EventBus ,
292
- message : str = "Trinity shudown complete \n " ) -> None :
294
+ reason : str = None ) -> None :
293
295
# When a user hits Ctrl+C in the terminal, the SIGINT is sent to all processes in the
294
296
# foreground *process group*, so both our networking and database processes will terminate
295
297
# at the same time and not sequentially as we'd like. That shouldn't be a problem but if
@@ -300,7 +302,9 @@ def kill_trinity_gracefully(logger: logging.Logger,
300
302
# Notice that we still need the kill_process_gracefully() calls here, for when the user
301
303
# simply uses 'kill' to send a signal to the main process, but also because they will
302
304
# perform a non-gracefull shutdown if the process takes too long to terminate.
303
- logger .info ('Keyboard Interrupt: Stopping' )
305
+
306
+ hint = f"({ reason } )" if reason else f""
307
+ logger .info ('Shutting down Trinity %s' , hint )
304
308
plugin_manager .shutdown_blocking ()
305
309
main_endpoint .stop ()
306
310
event_bus .stop ()
@@ -312,9 +316,7 @@ def kill_trinity_gracefully(logger: logging.Logger,
312
316
kill_process_gracefully (process , logger )
313
317
logger .info ('%s process (pid=%d) terminated' , name , process .pid )
314
318
315
- # This is required to be within the `kill_trinity_gracefully` so that
316
- # plugins can trigger a shutdown of the trinity process.
317
- ArgumentParser ().exit (message = message )
319
+ ArgumentParser ().exit (message = f"Trinity shutdown complete { hint } \n " )
318
320
319
321
320
322
@setup_cprofiler ('run_database_process' )
0 commit comments