diff --git a/README.md b/README.md new file mode 100644 index 0000000..9894e60 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +* modify doorcontrol.conf with your configuration +* move doorcontrol.conf to `/etc/doorcontrol/doorcontrol.conf` +* create `/usr/local/doorcontrol` directory +* create iot user +* change to iot user: `sudo -u iot -s` +* `chown iot:iot /usr/local/doorcontrol` +* create python virtual environment +* `python3 -m venv /usr/local/doorcontrol/venv` +* create `/usr/local/doorcontrol/src` directory +* move doorcontrol.py to `/usr/local/doorcontrol/src` +* activate virtual env: `source /usr/local/doorcontrol/venv/bin/activate` +* `pip install paho.mqtt, bottle` +* create uwsgi conf file, use example file and move to `/etc/uwsgi/apps-available` +* if using emperor mode: `ln -s /etc/uwsgi/apps-available/doorcontrol-uwsgi.ini /etc/uwsgi/vassels/doorcontrol-uwsgi.ini` +* modify nginx config: + location = /main-door { rewrite ^ /main-door/; } + location /main-door { + auth_basic off; + try_files $uri @main-door; } + location @main-door { + auth_basic off; + + include uwsgi_params; + uwsgi_pass unix:/run/uwsgi/app/doorcontrol/dc.sock; + } +* create dir `mkdir /run/uwsgi/app/doorcontrol` +* chown iot:www-data + diff --git a/doorcontrol-uwsgi.ini b/doorcontrol-uwsgi.ini new file mode 100644 index 0000000..d37ca4c --- /dev/null +++ b/doorcontrol-uwsgi.ini @@ -0,0 +1,34 @@ +[uwsgi] + +strict = true + +uid = iot +gid = www-data + +socket = /run/uwsgi/app/doorcontrol/dc.sock + +#disable-logging = true + +workers = 4 + +chmod-socket = 664 + +single-interpreter = true +master = true +plugin = python3,http +lazy-apps = true +enable-threads = true + +### The followint 2 lines are important if we arent mounted at root of url +manage-script-name = true +mount = /main-door=app:app + +#wsgi-file = app.py +#module = app:app +#route-run = fixpathinfo: + +virtualenv = /usr/local/doorcontrol/venv +pythonpath = /usr/local/doorcontrol/venv/bin +chdir = /usr/local/doorcontrol/src + +daemonize = /var/log/uwsgi/doorcontrol.log