L2-Technology / sensei

A lightning node implementation for everyone
https://l2.technology/sensei
Other
199 stars 39 forks source link

fix graph persistence bug and add proper shutdown handling #102

Closed johncantrell97 closed 2 years ago

johncantrell97 commented 2 years ago

Fixed a couple issues here:

1) The network graph is persisted by the background processor but only every 10 minutes. The only other time it is supposed to be persisted is on shutdown. The big issue here is there was no proper shutdown handling in Sensei. This means handling termination signals like SIGINT/SIGTERM/SIGQUIT and then gracefully shutting down. This PR adds hooks for these signals, sets an AtomicBool / flag to true saying we've received signal to shutdown. It then triggers proper shutdown of every running node, the p2p background processor (to persist graph/scorer), and chain manager.

2) There was a big typo where it was persisting the network graph with the key "network_graph" and reading it from the key "graph" causing it to never actually load the persisted graph on subsequent startups. This also fixes that.