From 49bd5ad26bffa5f4cce8ce6a9f2bbeb4e874140d Mon Sep 17 00:00:00 2001 From: matthewcroughan Date: Fri, 8 Jul 2022 09:24:54 +0100 Subject: [PATCH] lnbits/server.py: init This adds a wrapper around uvicorn using Python. This is so the entrypoint lnbits.server can be called on the command line, and passed arguments like port and host. This makes lnbits feel more like a real CLI application, and lends well to running as a service in systemd --- lnbits/server.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lnbits/server.py diff --git a/lnbits/server.py b/lnbits/server.py new file mode 100644 index 000000000..c0efb8953 --- /dev/null +++ b/lnbits/server.py @@ -0,0 +1,17 @@ +import uvicorn + +import click + +@click.command() +@click.option('--port', default="5000", help='Port to run LNBits on') +@click.option('--host', default="127.0.0.1", help='Host to run LNBits on') +def main(port, host): + """Launched with `poetry run lnbits` at root level""" + uvicorn.run("lnbits.__main__:app", port=port, host=host) + +if __name__ == '__main__': + main() + +#def main(): +# """Launched with `poetry run start` at root level""" +# uvicorn.run("lnbits.__main__:app")