How to use uWSGI Avahi plugin in Ubuntu

Step-by-step how-to to use uWSGI Avahi plugin for GNU/Linux (tested on Ubuntu 17.04/17.10).

© 2017 Paolo Melchiorre CC BY-SA “Photo taken in the historic center of Rimini (Italy) during the EuroPython 2017”
© 2017 Paolo Melchiorre CC BY-SA “Photo taken in the historic center of Rimini (Italy) during the EuroPython 2017”
Development with uWSGI (3 part series)
  1. How to use uWSGI with Python3.6 in Ubuntu
  2. How to use uWSGI Avahi plugin in Ubuntu
  3. How to use uWSGI with Python 3.7 in Ubuntu 18

The Avahi uWSGI plugin (github.com/20tab/uwsgi-avahi) allows your instances to register services in your mDNS system.

$ sudo apt install \
libavahi-client-dev \
uwsgi \
uwsgi-src
$ cd ~
$ export PYTHON=python3.6
$ uwsgi --build-plugin \
https://github.com/20tab/uwsgi-avahi
$ sudo mv \
avahi_plugin.so \
/usr/lib/uwsgi/plugins/avahi_plugin.so
$ sudo chmod 644 \
/usr/lib/uwsgi/plugins/avahi_plugin.so

Configuring your .ini file like:

[uwsgi]

project_name = paulox
socket = 127.0.0.1:0
subscribe-to = 127.0.0.1:5005:%(project_name).local
plugins = avahi
avahi-register = %(project_name).local

After starting your emperor you can view some similar messages on your log:


Avahi Server Version: avahi 0.6.32
[uwsgi-avahi] registered record paulox.local CNAME ubuntu.local