Solve UWSGI service not started in Ubuntu


I found some weird bug when install uwsgi in Ubuntu 13.10 and 14.04 (after upgrade). When i run :

1
sudo service uwsgi start

No uwsgi services started and .ini are completely fine (executed with “uwsgi –ini my-app.ini”).
I found simple solution by uninstall and reinstall uwsgi packages

1
2
sudo apt-get remove –purge uwsgi uwsgi-plugin-python
sudo apt-get install uwsgi uwsgi-plugin-python

But careful, when you already did this but “service uwsgi start” result is “fail” or no uwsgi service started, it’s because www-data permission can’t write into root folder.

Please use “pidfile2” instead of “pidfile”. Here is some example :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[uwsgi]
# enable master process manager
master = true

# spawn 2 uWSGI worker processes
workers = 4

# bind to UNIX socket at /run/uwsgi/<confnamespace>/<confname>/socket
socket = /tmp/polatic.sock

# set mode of created UNIX socket
chmod-socket = 666

# place timestamps into log
log-date = true

# user identifier of uWSGI processes
uid = www-data

# group identifier of uWSGI processes
gid = www-data

; define variables to use in this script
project = polatic

; number of worker processes
processes = 2

plugins=python
; project-level logging to the logs/ folder
logto = /tmp/polatic-uwsgi.log

; django >= 1.4 project
chdir = /var/polatic
wsgi-file=/var/polatic/polatic/wsgi.py

; run master process as root
enable-threads = true
processes = 10

vacuum = true
;env = DJANGO_SETTINGS_MODULE=djtest.settings
;module = polatic.wsgi:application
env = DJANGO_SETTINGS_MODULE=vasham.settings
pidfile2 = /tmp/polatic.pid
;harakiri = 20 # respawn processes taking more than 20 seconds
;max-requests = 5000 # respawn processes after serving 5000 requests

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.