1
0
mirror of https://github.com/etesync/server synced 2024-11-22 16:58:08 +00:00

Edit basic setup to include uvicorn

Simon Vandevelde 2020-12-29 19:20:37 +01:00
parent 9c7e46cdac
commit 22d14bc69f

@ -14,7 +14,6 @@ $ apt-get install python3-virtualenv
$ cd ~ # To set up the server in your home dir $ cd ~ # To set up the server in your home dir
$ git clone https://github.com/etesync/server etebase $ git clone https://github.com/etesync/server etebase
$ cd etebase $ cd etebase
$ git checkout etebase
$ virtualenv -p python3 .venv # If doesn't work, try: virtualenv3 .venv $ virtualenv -p python3 .venv # If doesn't work, try: virtualenv3 .venv
$ source .venv/bin/activate $ source .venv/bin/activate
@ -54,22 +53,35 @@ allowed_host1 = *
engine = django.db.backends.sqlite3 engine = django.db.backends.sqlite3
name = db.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 ### Test the application
After initializing the server, we can test it by running it for the first time. 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 server at port `8000`. We will do this by running the uvicorn server at port `8000`.
``` ```
$ ./manage.py migrate $ ./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!" 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 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! If this works, congratulations!
You now have a functioning Django application. You now have a functioning Django application.
This is not yet a production setup however. 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.** **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.**