From 7cb5e096b5a4b965b7ff86f6741c823db92146aa Mon Sep 17 00:00:00 2001 From: W13R <9070224-W13R@users.noreply.gitlab.com> Date: Wed, 16 Mar 2022 18:27:05 +0100 Subject: [PATCH] Switch from hypercorn to uvicorn --- docs/Commands.md | 2 +- docs/Setup.md | 9 ++------- lib/bootstrap.py | 9 ++++++--- pip-dependencies.txt | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/Commands.md b/docs/Commands.md index 2cc39ca..68ebe71 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -11,7 +11,7 @@ You run a command with --- `server` - Start the server -This starts a caddy instance, hypercorn with the django application and a scheduler that automatically removes expired session data. +This starts a caddy instance, uvicorn with the django application and a scheduler that automatically removes expired session data. Log files will be written. --- diff --git a/docs/Setup.md b/docs/Setup.md index 11f2ee4..4f5940f 100644 --- a/docs/Setup.md +++ b/docs/Setup.md @@ -18,14 +18,9 @@ Before the actual setup, you have to satisfy the following dependencies: ### Python Packages (pip) -- `django~=3.2.7` -- `django-currentuser==0.5.3` -- `django-csp==3.7` -- `psycopg2~=2.9.1` -- `hypercorn~=0.11.2` -- `cryptography~=36.0.0` (for self-signed tls certificates) +All required python packages are listed `in pip-dependencies.txt` -You can install those pip-packages with the following command: +You can install the required python packages with the following command: ```bash pip install -U -r pip-dependencies.txt ``` diff --git a/lib/bootstrap.py b/lib/bootstrap.py index 2ce6bce..7fc3286 100644 --- a/lib/bootstrap.py +++ b/lib/bootstrap.py @@ -50,7 +50,7 @@ print(f"HTTP Access Log will be written to {CADDY_ACCESS_LOG}") try: - # start django/hypercorn + # start django/uvicorn if devel: run( @@ -75,7 +75,10 @@ try: ) app_process = Popen( [ - "hypercorn", "--bind", quote(f"localhost:{DJANGO_PORT}"), "drinks_manager.asgi:application" + "uvicorn", + "--host", "localhost", + "--port", quote(DJANGO_PORT), + "drinks_manager.asgi:application" ], stdout=application_log_file, stderr=application_log_file, @@ -137,7 +140,7 @@ except KeyboardInterrupt: if devel: print(f"Django stopped with exit code {app_process.returncode}.") else: - print(f"Django/Hypercorn stopped with exit code {app_process.returncode}.") + print(f"Django/Uvicorn stopped with exit code {app_process.returncode}.") if caddy_process.returncode != 0 or scs_process.returncode != 0 or app_process.returncode !=0: exit(1) diff --git a/pip-dependencies.txt b/pip-dependencies.txt index b75bd9a..61287a1 100644 --- a/pip-dependencies.txt +++ b/pip-dependencies.txt @@ -2,5 +2,5 @@ django~=3.2.7 django-currentuser==0.5.3 django-csp==3.7 psycopg2~=2.9.1 -hypercorn~=0.11.2 -cryptography~=36.0.0 \ No newline at end of file +uvicorn~=0.17.6 +cryptography~=36.0.0