Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting uWSGI service fails silently

I'm having a problem which is driving me nuts. I'm trying to create an Ubuntu 15.04 Upstart job, which would start uWSGI server (uWSGI version 2.0.7-debian) running a Django application.

I've configured the service as a follows and try to start the job by issuing command $ sudo service uwsgi start. There is no output in log files, no socket file created and no error.

# file: /etc/init/uwsgi.conf

description "uWSGI server"

start on runlevel [2345]
stop on runlevel [!2345]

exec /usr/bin/uwsgi --ini /srv/configs/uwsgi.ini

service uwsgi status says

● uwsgi.service - LSB: Start/stop uWSGI server instance(s)
Loaded: loaded (/etc/init.d/uwsgi)
Active: active (exited) since Tue 2015-05-05 09:40:08 EEST; 1s ago
  Docs: man:systemd-sysv-generator(8)
Process: 21405 ExecStop=/etc/init.d/uwsgi stop (code=exited, status=0/SUCCESS)
Process: 21460 ExecStart=/etc/init.d/uwsgi start (code=exited, status=0/SUCCESS)

May 05 09:40:08 web-2 systemd[1]: Starting LSB: Start/stop uWSGI server instance(s)...
May 05 09:40:08 web-2 uwsgi[21460]: * Starting app server(s) uwsgi
May 05 09:40:08 web-2 uwsgi[21460]: ...done.
May 05 09:40:08 web-2 systemd[1]: Started LSB: Start/stop uWSGI server instance(s).

The uWSGI app is configured as

[uwsgi]

uid = www-data
gid = www-data
socket = /srv/sockets/uwsgi.sock
chmod-socket = 666
master = true
processes = 4
enable-threads = true
plugins = python
chdir = /srv/sites/current
module = wsgi:application
virtualenv = /srv/environments/current
logto = /srv/logs/uwsgi.log
logfile-chown = true
touch-reload = /srv/sites/current/wsgi.py

The service starts fine and everything works ok if the service is started directly, e.g. by issuing command: sudo -u www-data /usr/bin/uwsgi --ini /srv/configs/uwsgi.ini

For the socket dir and log files directories I've set the most relaxed permissions.

So, I'm at a loss. What to do next?

like image 505
samuke Avatar asked May 05 '15 06:05

samuke


People also ask

How do I turn off uWSGI?

Stopping the server If you have the uWSGI process running in the foreground for some reason, you can just hit CTRL+C to kill it off. When dealing with background processes, you'll need to use the master pidfile again. The SIGINT signal will kill uWSGI.

What is Linux uWSGI?

uWSGI is an open source software application that "aims at developing a full stack for building hosting services". It is named after the Web Server Gateway Interface (WSGI), which was the first plugin supported by the project.

How do I enable threads on uWSGI?

You must enable uWSGI threads by adding the --enable-threads option in the uwsgi command. This option is applied automatically when you specify the --threads option to configure the number of threads.


1 Answers

Thanks to nmgeeks comment, I started looking at other places where uWSGI is configured.

While trying to move everything our own app related under /srv I deleted /run/uwsgi directory, where uWSGI is trying to create a PID file.

You can find the reference at /usr/share/uwsgi/conf/default.ini.

Too bad uWSGI doesn't produce any error in this situation, which left me frustrated for a day.

like image 184
samuke Avatar answered Oct 01 '22 01:10

samuke