fusion44 / blitz_api

A management backend for the RaspiBlitz project written in Python / FastAPI
MIT License
19 stars 18 forks source link

BlitzApi fails to start on fresh sd card image for Setup #71

Closed rootzoll closed 2 years ago

rootzoll commented 2 years ago

I want to test the blitzapi for setup - so I take a fresh sd card image and run blitz.web.api.sh on ... but the blitzapi service is in constant restart - this is the error:

positories/bitcoin.py:98> exception=ClientConnectorError(ConnectionKey(host='127.0.0.1', port=8332, is_ssl=False, ssl=None, proxy=None, proxy_auth=None, proxy_headers_hash=-5554264851534051820), ConnectionRefusedError(111, "Connect call failed ('127.0.0.1', 8332)"))>
Mar 18 10:49:54 raspberrypi sudo[66277]: Traceback (most recent call last):
Mar 18 10:49:54 raspberrypi sudo[66277]:   File "/home/admin/.local/lib/python3.9/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
Mar 18 10:49:54 raspberrypi sudo[66277]:     return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
Mar 18 10:49:54 raspberrypi sudo[66277]:   File "/usr/lib/python3.9/asyncio/base_events.py", line 1056, in create_connection
Mar 18 10:49:54 raspberrypi sudo[66277]:     raise exceptions[0]
Mar 18 10:49:54 raspberrypi sudo[66277]:   File "/usr/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
Mar 18 10:49:54 raspberrypi sudo[66277]:     sock = await self._connect_sock(
Mar 18 10:49:54 raspberrypi sudo[66277]:   File "/usr/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
Mar 18 10:49:54 raspberrypi sudo[66277]:     await self.sock_connect(sock, address)
Mar 18 10:49:54 raspberrypi sudo[66277]:   File "/usr/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
Mar 18 10:49:54 raspberrypi sudo[66277]:     return await fut
Mar 18 10:49:54 raspberrypi sudo[66277]:   File "/usr/lib/python3.9/asyncio/selector_events.py", line 537, in _sock_connect_cb
Mar 18 10:49:54 raspberrypi sudo[66277]:     raise OSError(err, f'Connect call failed {address}')
Mar 18 10:49:54 raspberrypi sudo[66277]: ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 8332)
Mar 18 10:49:54 raspberrypi sudo[66277]: The above exception was the direct cause of the following exception:
Mar 18 10:49:54 raspberrypi sudo[66277]: Traceback (most recent call last):
Mar 18 10:49:54 raspberrypi sudo[66277]:   File "./app/repositories/bitcoin.py", line 102, in _handle_gather_bitcoin_status

So it seems the blitzapi does not start if there no bitcoind/lnd yet. How can we make the API tolerate a missing bitcoind/lnd until its available?

fusion44 commented 2 years ago

At which setup step can we assume that Bitcoin Core and a LN node is fully available to connect to?

From Redis:

setupStep="100"
setupPhase="done"
state="ready"

I'd say that I check for the setupStep and turn off all non-setup functionality below a certain value. Then I could listen to changes to setupStep or wait for a reboot when the system is finished setting up lightning.

rootzoll commented 2 years ago

OK this looks good now. Closing.