JiriSko / amixer-webui

Web application for control ALSA volume
MIT License
53 stars 21 forks source link

uwsgi implementation #20

Open gearhead opened 3 years ago

gearhead commented 3 years ago

JiriSko,

Been using this for a while. We recently made some changes and wanted to share with you. I am not a coder, so it took me a while to get this working, but when using the python flask app on port 8080, there is always a message in the log about it being insecure. We are running nginx and we made these changes to get it all working as a uwsgi socket 1) install : uwsgi and uwsgi-python 2) make these changes nginx.conf:

...
        # add uwsgi for amixer-webui
        server {
            listen 8080;
            listen [::]:8080;

            location /
            {
            root /usr/share/amixer-webui;
                # logging and control is in the amixer-webui.ini file
            include uwsgi_params;
            uwsgi_pass unix:/run/uwsgi/amixer-webui.sock;
          }
        } # end amixer-webui section
...

We install it in /srv/http/amixer and have these config files: wsgi.py:

from alsamixer_webui import app
if __name__ == "__main__":
    app.run()

amixer-webui.ini

[uwsgi]
module = wsgi
module = alsamixer_webui:app
plugins = python
processes = 1
#threads = 2
# the user and group id of the process once it’s started
uid = http
gid = http
socket = /run/uwsgi/%n.sock
#http = 0.0.0.0:8080 # for testing
master = true
chdir = /srv/http/amixer
# Logging
#logto = /var/log/amixer-webui.log
logto = /dev/null
log-5xx = true
disable-logging = true
# clear environment on exit
vacuum = true
die-on-term = true

In the systemd service file, we use this as the execute line: ExecStart=/usr/bin/uwsgi --ini /srv/http/amixer/amixer-webui.ini

dagent commented 8 months ago

Thank you so much! I can use that :100: