mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-10 00:09:22 +01:00
support uvicorn reload functionality (#1841)
* support uvicorn reload functionality
see:
8239373ec6/uvicorn/main.py (L580-L582)
* add docs for --reload
---------
Co-authored-by: dni ⚡ <office@dnilabs.com>
This commit is contained in:
parent
2577ce7f81
commit
772ae2a1ab
3 changed files with 27 additions and 1 deletions
3
Makefile
3
Makefile
|
@ -36,6 +36,9 @@ checkblack:
|
|||
checkisort:
|
||||
poetry run isort --check-only .
|
||||
|
||||
dev:
|
||||
poetry run lnbits --reload
|
||||
|
||||
test:
|
||||
LNBITS_BACKEND_WALLET_CLASS="FakeWallet" \
|
||||
FAKE_WALLET_SECRET="ToTheMoon1" \
|
||||
|
|
|
@ -12,6 +12,21 @@ For developers
|
|||
Thanks for contributing :)
|
||||
|
||||
|
||||
Run
|
||||
=====
|
||||
|
||||
This starts the lnbits uvicorn server
|
||||
```bash
|
||||
poetry run lnbits
|
||||
```
|
||||
|
||||
This starts the lnbits uvicorn with hot reloading.
|
||||
```bash
|
||||
make dev
|
||||
# or
|
||||
poetry run lnbits --reload
|
||||
```
|
||||
|
||||
Precommit hooks
|
||||
=====
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import uvloop
|
||||
from uvicorn.supervisors import ChangeReload
|
||||
|
||||
uvloop.install()
|
||||
|
||||
|
@ -73,7 +74,14 @@ def main(
|
|||
)
|
||||
|
||||
server = uvicorn.Server(config=config)
|
||||
process = mp.Process(target=server.run)
|
||||
|
||||
if config.should_reload:
|
||||
sock = config.bind_socket()
|
||||
run = ChangeReload(config, target=server.run, sockets=[sock]).run
|
||||
else:
|
||||
run = server.run
|
||||
|
||||
process = mp.Process(target=run)
|
||||
process.start()
|
||||
server_restart.wait()
|
||||
server_restart.clear()
|
||||
|
|
Loading…
Add table
Reference in a new issue