uwsgi: strange messages

1,467 views
Skip to first unread message

Martin Weissenboeck

unread,
Feb 3, 2015, 2:56:39 AM2/3/15
to web2py-users
Two questions about uwsgi:

(1) Server one: I have installed nginx+uwsgi using the script on a test server. web2py works fine, but the uwsgi.log file shows a new entry every second (marked red).
And there is a warning (green) - how can I run uWSGI not as root?
This is the logfile after a restart (sorry, I know, there are many lines):

*** Starting uWSGI 2.0.9 (64bit) on [Tue Feb  3 08:25:09 2015] ***
compiled with version: 4.8.2 on 18 January 2015 11:43:22
os: Linux-3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your processes number limit is 15784
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
Python version: 2.7.6 (default, Mar 22 2014, 23:03:41)  [GCC 4.8.2]
*** starting uWSGI Emperor ***
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from web2py.ini
*** Starting uWSGI 2.0.9 (64bit) on [Tue Feb  3 08:25:09 2015] ***
compiled with version: 4.8.2 on 18 January 2015 11:43:22
os: Linux-3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014
nodename: mweissen-test
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
set additional group 125 (dovecot)
setuid() to 33
your processes number limit is 15784
limiting address space of processes...
your process address space limit is 536870912 bytes (512 MB)
your memory page size is 4096 bytes
 *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/web2py.socket fd 3
Python version: 2.7.6 (default, Mar 22 2014, 23:03:41)  [GCC 4.8.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1865760
your mercy for graceful operations on workers is 60 seconds
*** Operational MODE: no-workers ***
spawned uWSGI master process (pid: 35875)
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1a07a90
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
[uwsgi-cron] command "python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o" registered as cron task
mapped 363840 bytes (355 KB) for 4 cores
*** Operational MODE: preforking ***
added /home/www-data/web2py/ to pythonpath.
mounting wsgihandler:application on /
worker 1 killed successfully (pid: 35873)
Respawned uWSGI worker 1 (new pid: 35885)
mapping worker 1 to CPUs: 0
emperor-i-am-ready-to-accept/write(): Bad file descriptor [core/uwsgi.c line 3453]
Tue Feb  3 08:25:09 2015 - lost communication with the Emperor, goodbye...
Tue Feb  3 08:25:09 2015 - graceful shutdown triggered...
Gracefully killing worker 1 (pid: 35885)...
WSGI app 0 (mountpoint='/') ready in 0 seconds on interpreter 0x1a07a90 pid: 35878 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 35878)
Tue Feb  3 08:25:09 2015 - [emperor] vassal web2py.ini has been spawned
spawned uWSGI worker 1 (pid: 35888, cores: 1)
spawned uWSGI worker 2 (pid: 35889, cores: 1)
spawned uWSGI worker 3 (pid: 35890, cores: 1)
spawned uWSGI worker 4 (pid: 35891, cores: 1)
*** Stats server enabled on /tmp/stats.socket fd: 16 ***
mapping worker 2 to CPUs: 0
mapping worker 3 to CPUs: 0
mapping worker 4 to CPUs: 0
mapping worker 1 to CPUs: 0
Tue Feb  3 08:25:09 2015 - [emperor] vassal web2py.ini is ready to accept requests
worker 1 killed successfully (pid: 35885)
worker respawning too fast !!! i have to sleep a bit (2 seconds)...
Respawned uWSGI worker 1 (new pid: 35892)
mapping worker 1 to CPUs: 0
emperor-i-am-ready-to-accept/write(): Bad file descriptor [core/uwsgi.c line 3453]
Tue Feb  3 08:25:12 2015 - lost communication with the Emperor, goodbye...
Tue Feb  3 08:25:12 2015 - graceful shutdown triggered...
Gracefully killing worker 1 (pid: 35892)...
worker 1 killed successfully (pid: 35892)
Respawned uWSGI worker 1 (new pid: 35893)
mapping worker 1 to CPUs: 0
emperor-i-am-ready-to-accept/write(): Bad file descriptor [core/uwsgi.c line 3453]
Tue Feb  3 08:25:13 2015 - lost communication with the Emperor, goodbye...
Tue Feb  3 08:25:13 2015 - graceful shutdown triggered...
Gracefully killing worker 1 (pid: 35893)...
worker 1 killed successfully (pid: 35893)

(2) Server two (for the production): it should be the same installation, but now the uwsgi.log file contains:

mounting wsgihandler:application on /
spawned uWSGI master process (pid: 1167)
Traceback (most recent call last):
  File "/home/www-data/web2py/wsgihandler.py", line 37, in <module>
    import gluon.main
  File "/home/www-data/web2py/gluon/__init__.py", line 15, in <module>
    from globals import current
  File "/home/www-data/web2py/gluon/globals.py", line 21, in <module>
    from gluon.html import xmlescape, TABLE, TR, PRE, URL
  File "/home/www-data/web2py/gluon/html.py", line 34, in <module>
    from gluon.utils import web2py_uuid, simple_hash, compare
  File "/home/www-data/web2py/gluon/utils.py", line 44, in <module>
    import hmac
  File "/usr/local/lib/python2.7/hmac.py", line 8, in <module>
    from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
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: 1213)
Tue Feb  3 08:12:12 2015 - [emperor] vassal web2py.ini has been spawned
spawned uWSGI worker 1 (pid: 1310, cores: 1)
mapping worker 1 to CPUs: 0
spawned uWSGI worker 2 (pid: 1311, cores: 1)
spawned uWSGI worker 3 (pid: 1312, cores: 1)
spawned uWSGI worker 4 (pid: 1313, cores: 1)
*** Stats server enabled on /tmp/stats.socket fd: 16 ***
mapping worker 4 to CPUs: 1
mapping worker 2 to CPUs: 1
Tue Feb  3 08:12:12 2015 - [emperor] vassal web2py.ini is ready to accept requests
mapping worker 3 to CPUs: 0

I have spent some hours, but I could not find a solution.
Who can give me a hint?

Regards, Martin



Niphlod

unread,
Feb 3, 2015, 3:18:51 AM2/3/15
to web...@googlegroups.com, mwei...@gmail.com
the " from operator import _compare_digest as compare_digest" is documented on the interwebs.... just google it... "standard issues" are playing with different versions of python in the same server.
the "how do I run it not from root".... well. Don't start uwsgi while logged in as root ! You stated this is the result of installing nginx+uwsgi using "the script on a test server" ............ if the script is this it has the correct permissions to AVOID running as root.... if the script is another one..... it's wrong.


Martin Weissenboeck

unread,
Feb 4, 2015, 2:20:18 AM2/4/15
to Niphlod, web2py-users
You are right, there is a lot of entries about "from operator..." and I have tried some proposlas, but without success. Therefore I postet my question here.

Anyway, your hints was helpful - thank you: it seems that there are diffenent libraries "python2.7": I wanted to use Python 2.7.9, but uwsgi expected Python 2.7.6

Maybe it is possible to use Python 2.7.9 together with web2py and 2.7.6 for the rest of the Ubuntu server, but I had not enough time to try it.

c...@cemeren.com

unread,
Feb 13, 2015, 4:52:02 PM2/13/15
to web...@googlegroups.com, mwei...@gmail.com
I used the same script to setup nginx and uwsgi and it helped me a lot speeding up my learning process, as it is almost turnkey. I had the same warning message for uid though it has been clearly configured in web2py.ini. I just added --uid param to the exec command and did not further investigate why uwsgi did not read properly that parameter from the ini file.
Reply all
Reply to author
Forward
0 new messages