Uwsgi socket problems

Hi,

I do not know if others than me had this problem with the uwsgi stats socket. Or if I made a mistake following the documentation.

I installed Indico with Centos 7 and Apache.

In the uWSGI configuration section I see this option :

stats = /opt/indico/web/uwsgi-stats.sock

but in the default uwsgi service file /usr/lib/systemd/system/uwsgi.service , there is a hard-coded socket and PIDfile entry :

ExecStart=/usr/sbin/uwsgi --ini /etc/uwsgi.ini --pidfile /run/uwsgi/uwsgi.pid --stats /run/uwsgi/stats.sock

It seems that this option overwides the socket in the configuration file.

With this configuration, I am forced to create a /run/uwsgi/ directory with owner indico and group apache and then the service starts and I see the socket

# ls -l /run/uwsgi 
total 4
srwxr-x---. 1 indico apache 0 jui  6 08:15 stats.sock
-rw-r-----. 1 root   root   6 jui  6 08:15 uwsgi.pid

The socket /opt/indico/web/uwsgi-stats.sock does not seems to be used

# ls -l /opt/indico/web/uwsgi-stats.sock
ls: cannot access /opt/indico/web/uwsgi-stats.sock: No such file or directory

The big problem with this is after a server reboot, the owner:group of /run/uwsgi/ changes to uwsgi:uwsgi and uwsgi can not start until I change the owner:group to indico:apache again.

To solve this problem, I created a new service indico-uwsgi.service

[Unit]
Description=uWSGI Emperor Service
After=syslog.target

[Service]
EnvironmentFile=-/etc/sysconfig/uwsgi
ExecStart=/usr/sbin/uwsgi --ini /etc/uwsgi.ini --pidfile /opt/indico/web/uwsgi.pid --stats /opt/indico/web/uwsgi-stats.sock
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
Restart=always
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target

disable the uwsgi default service and enable/start this one.

In addition to this, I think there is a typo in the SELinux configuration

(filecon "/opt/indico/web/**uwsgi\.sock**" socket (system_u object_r httpd_sys_rw_content_t ((s0)(s0))))

Should not be uwsgi-stats.sock instead ?

Regards

Juan Cabrera

Please try this, as mentioned in another forum thread and the updated setup guide:

mkdir -p /etc/systemd/system/uwsgi.service.d
cat > /etc/systemd/system/uwsgi.service.d/old-exec-start.conf <<'EOF'
[Service]
ExecStart=
ExecStart=/usr/sbin/uwsgi --ini /etc/uwsgi.ini
EOF

followed by systemctl daemon-reload and systemctl restart uwsgi.service

That way you don’t need to override the whole systemd unit file.

No. The stats socket is not used by nginx so it does not need access to it.

Thanks for your fast reply. I added this and works fine.

So I think I do something wrong because I do not have a /opt/indico/web/uwsgi.sock in the directory

# ls -l /opt/indico/web/
total 8
-rw-r--r--. 1 indico apache 281 jui  6 07:23 indico.wsgi
lrwxrwxrwx. 1 indico apache  63 jui  6 07:23 static -> /opt/indico/.venv/lib/python2.7/site-packages/indico/web/static
-rw-r-----. 1 root   root     5 jui  6 09:13 uwsgi.pid
srwxr-x---. 1 indico apache   0 jui  6 10:16 uwsgi-stats.sock

It only shows up when uwsgi is running… And if you use Apache then you won’t have it at all because Apache connects through a normal TCP/IP socket to uWSGI.