Repository navigation
Set up TLS, the gRPC listener and signals before starting the node - #330
Conversation
|
👋 Thanks for assigning @benthecarman as a reviewer! |
|
Hi @benthecarman, when you have time, could you take a look at this? It sets up TLS, the gRPC bind and the signal handlers before One decision I'd like your input on: the lock adds a direct |
benthecarman
left a comment
There was a problem hiding this comment.
the second commit is not needed, we do this in our database already.
also please don't just have AI write your entire PR desc and commit message without you cleaning it up first
c76e970 to
314b973
Compare
Thanks, dropped the lock commit and shortened the commit message and description. I had added the long write-up and repro output just to show the issue was real, but I understand it was too much. I’ve kept only a short summary. |
314b973 to
7f9ba71
Compare
7f9ba71 to
61aba2b
Compare
We loaded the TLS config, bound the gRPC port and registered the signal handlers only after `node.start()`. If the port was already in use we panicked, which with `panic = "abort"` kills a node that is already running without `node.stop()`. A TLS setup failure did the same, and a SIGTERM or Ctrl-C received during `node.start()` killed the process without a graceful shutdown. Now we load the TLS config and bind the listener before starting the node, exiting with an error if either fails, and register the SIGHUP, SIGTERM and SIGINT handlers up front. Signals received during startup are handled by the main loop once the node is running. This still happens after building the node, so a restarting instance keeps waiting for a Postgres lease held by the previous one.
61aba2b to
31bcdff
Compare
We loaded the TLS config, bound the gRPC port and registered the signal handlers only after
node.start(). If the port was already in use we panicked, which withpanic = "abort"kills a node that is already running without callingnode.stop(). A SIGTERM or Ctrl-C duringnode.start()killed the process without a graceful shutdown.Now we load the TLS config and bind the listener before starting the node, exiting with an error if either fails, and register the SIGHUP, SIGTERM and SIGINT handlers up front. Signals received during startup are handled by the main loop once the node is running. This still happens after building the node, so a restarting instance keeps waiting for a Postgres lease held by the previous one.
Tested against a mock Esplora server:
Failed to bind gRPC service addressbefore starting the node.node.start(): before, the process was killed (exit -15). Now it shuts down gracefully (exit 0).Added e2e test
test_config_fail_grpc_address_in_use. It compiles, but I couldn't run it locally because it needs bitcoind.