From 22d14bc69fb2f37b75a26ec0f05b9de10693908a Mon Sep 17 00:00:00 2001 From: Simon Vandevelde Date: Tue, 29 Dec 2020 19:20:37 +0100 Subject: [PATCH] Edit basic setup to include uvicorn --- Basic-Setup-Etebase-(EteSync-v2).md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Basic-Setup-Etebase-(EteSync-v2).md b/Basic-Setup-Etebase-(EteSync-v2).md index 11b2bfd..f9edf60 100644 --- a/Basic-Setup-Etebase-(EteSync-v2).md +++ b/Basic-Setup-Etebase-(EteSync-v2).md @@ -14,7 +14,6 @@ $ apt-get install python3-virtualenv $ cd ~ # To set up the server in your home dir $ git clone https://github.com/etesync/server etebase $ cd etebase -$ git checkout etebase $ virtualenv -p python3 .venv # If doesn't work, try: virtualenv3 .venv $ source .venv/bin/activate @@ -54,22 +53,35 @@ allowed_host1 = * engine = django.db.backends.sqlite3 name = db.sqlite3 ``` +## Set up ASGI server + +Next, we set up an [ASGI server](https://asgi.readthedocs.io/en/latest/), which will serve as a way to interface with our application. +We advise using [uvicorn](https://www.uvicorn.org/), but other ASGI servers such as [Daphne](https://github.com/django/daphne) will also work. +Please note that WSGI is no longer supported, so if you have an older setup using uWSGI you will have to change to ASGI. + + +Installing uvicorn is easily done via pip. Make sure to install it inside your virtual environment if you are using one. + +``` +pip3 install uvicorn[standard] +``` + ### Test the application -After initializing the server, we can test it by running it for the first time. -We will do this by running the server at port `8000`. +After initializing the server and installing uvicorn, we can test the application by running it for the first time. +We will do this by running the uvicorn server at port `8000`. ``` $ ./manage.py migrate -$ ./manage.py runserver 0.0.0.0:8000 +$ uvicorn etebase_server.asgi:application --port 8000 --host 0.0.0.0 ``` -On the machine, you can now surf to `localhost:8000` and it should show a page saying "It works!" -If you're on a different machine than the one running the server, surf to its local IP address followed by the port number, e.g. `192.168.x.x:8000`. +On the machine, you can now surf to `0.0.0.0:8000` and it should show a page saying "It works!" +If you're on a different machine than the one running the server, surf to its (local) IP address followed by the port number, e.g. `192.168.x.x:8000`. If this works, congratulations! You now have a functioning Django application. This is not yet a production setup however. -**Using this server in production is not recommended, so please continue to [this page](https://github.com/etesync/server/wiki/Production-setup-using-Daphne-and-Nginx) to set up a proper deployment.** \ No newline at end of file +**Using this server in production is not recommended, so please continue to [this page](https://github.com/etesync/server/wiki/Production-setup-using-Nginx) to set up a proper deployment.** \ No newline at end of file