PI 3.1dev2 + uwsgi + nginx : connect to PI's unix socket FAILs (111:Connection refused)?

@fredreichbier

I was getting nothing of any use in my logfile until I DISabled

	PI_LOGLEVEL  = 10
	PI_LOGFILE   = '/var/log/privacyidea/privacyidea.log'
-	PI_LOGCONFIG = '/etc/privacyidea/logging.cfg'

Not clear what my problem there is; I’d cribbed it from,

https://privacyidea.readthedocs.io/en/latest/installation/system/logging.html

… I’ll deal with that later …

NOW, my logs show

	/var/log/uwsgi/error.log

		*** Starting uWSGI 2.0.18 (64bit) on [Tue Aug 20 08:45:27 2019] ***
		...
		 *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers *** 

(don’t know what that’s about … as in nginx, “uwsgi_request_buffering on;” is the default, and it’s not DISabled here)

	...
	- SystemD socket activation detected -
	uwsgi socket 1 attached to UNIX address /run/uwsgi/privacyidea.sock fd 3
	Python version: 3.6.5 (default, Mar 31 2018, 19:45:04) [GCC]
	Python main interpreter initialized at 0x55b16b657b00
	python threads support enabled
	your server socket listen backlog is limited to 100 connections
	your mercy for graceful operations on workers is 60 seconds
	mapped 364600 bytes (356 KB) for 4 cores
	*** Operational MODE: preforking ***
	Traceback (most recent call last):
	  File "/etc/privacyidea/privacyideaapp.wsgi", line 4, in <module>
	    from privacyidea.app import create_app
	ModuleNotFoundError: No module named 'privacyidea'
	unable to load app 0 (mountpoint='') (callable not found or import error)
	*** no app loaded. going in full dynamic mode ***
	*** uWSGI is running in multiple interpreter mode ***
	spawned uWSGI master process (pid: 38993)
	bind(): Permission denied [core/socket.c line 230]
	...brutally killing workers...
	VACUUM WARNING: unix socket /run/uwsgi/privacyidea.sock changed inode. Skip removal
	unlink(): No such file or directory [core/uwsgi.c line 1673]
	...

re-reading @cornelinux 's link, I needed to add a missing

	/etc/uwsgi/apps-available/privacyidea.ini
		...
+		venv = /opt/privacyidea
		...

for a fix.

now, on URL access,

	tail -f /var/log/uwsgi/error.log
		...
		*** Operational MODE: preforking ***
		The configuration name is: production
		Additional configuration can be read from the file /etc/privacyidea/pi.cfg
		The config file specified in PI_LOGCONFIG does not exist.
		Could not use PI_LOGCONFIG. Using PI_LOGLEVEL and PI_LOGFILE.
		Using PI_LOGLEVEL 10.
		Using PI_LOGFILE /var/log/privacyidea/privacyidea.log.
		WSGI app 0 (mountpoint='') ready in 3 seconds on interpreter 0x55dceb26a8d0 pid: 41996 (default app)
		*** uWSGI is running in multiple interpreter mode ***
		spawned uWSGI master process (pid: 41996)
		bind(): Permission denied [core/socket.c line 230]
		...brutally killing workers...
		VACUUM WARNING: unix socket /run/uwsgi/privacyidea.sock changed inode. Skip removal
		unlink(): No such file or directory [core/uwsgi.c line 1673]

so, a permission problem.

now to figure out why …