reth icon indicating copy to clipboard operation
reth copied to clipboard

exit forcefully if ctrl-c is Hit multiple times

Open mattsse opened this issue 2 years ago • 6 comments

Describe the feature

one ctrl-c triggers a graceful shutdown. double tap should exit immediately

Additional context

No response

mattsse avatar Feb 15 '23 10:02 mattsse

I'd like to take this

literallymarvellous avatar Feb 15 '23 13:02 literallymarvellous

nice, this is a bit challenging and I'm not quite sure yet how that would, this would require playing around tokio task internals a bit.

mattsse avatar Feb 15 '23 13:02 mattsse

yeah, this will take a while, I guess I knock out easier issues, while I sort this out.

literallymarvellous avatar Feb 15 '23 14:02 literallymarvellous

okay I think I know how to do this after reading https://tokio.rs/tokio/topics/shutdown

we need to make a few changes:

add async fn TaskExecutor::shutdown in which we drop the signal and also await on a new graceful shutdown channel that is used in spawn_with_signal that then can send back a response.

mattsse avatar Feb 16 '23 21:02 mattsse

Do we create a new signal in async fn TaskExecutor::shutdown or pass the one from TaskManager to it. Also, the Tokio example uses a mpsc::channel while the current implementation uses one shot::channel, wouldn't that need changing

literallymarvellous avatar Feb 17 '23 08:02 literallymarvellous

we need a new unbounded channel and we need to add a new GracefulShutdown struct that's Shutdown+ Sender<()>

the TaskManager holds the receiver and awaits until channel is done, which means all GracefulShutdown have been dropped.

mattsse avatar Feb 17 '23 11:02 mattsse

IMO we can close - this can potentially cause DB corruptions or not properly disconnect from all peers, and I'd rather avoid uncleaned state.

gakonst avatar Jul 03 '23 13:07 gakonst