Raphael Lechner | 15 Apr 10:55 2015

selenium/phanthomjs call is not working using nginx/apache2 and uwsgi


I’m trying to migrate my web2py application from apache2/wsgihandler.py to nginx/uwsgi and I found a strange issue,
that seems related to uwsgi.

I have a function that is calling phantomjs:

from selenium import webdriver
driver = webdriver.PhantomJS('phantomjs')

from the command line and via apache2/wsgihandler.py the call is working fine. But calling the same function using nginx/uwsgi or apache2/uwsgi I always got
that error:

<class 'selenium.common.exceptions.WebDriverException'> Message: Can not connect to GhostDriver

count = 0
while not utils.is_connectable(self.port):
count += 1
if count == 30:
raise WebDriverException("Can not connect to GhostDriver")

Have I something wrong with the uwsgi configuration?
Or is that problem not related to uwsgi and maybe a web2py/selenium/phantomjs issue?

I tried calling the function from a dedicated file but I always the same error.

My uwsgi configuration:
Ubuntu 14.04

socket = /tmp/web2py.socket
pythonpath = /home/www-data/web2py/
mount = /=wsgihandler:application
processes = 4
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
stats = /tmp/stats.socket
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
uid = www-data
gid = www-data
cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o
no-orphans = true
enable-threads = true

uwsgi --version

location / {
            uwsgi_pass      unix:///tmp/web2py.socket;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;

Thank you for any response!

uWSGI mailing list
Daniel Holth | 13 Apr 20:55 2015

http://uwsgi-docs.readthedocs.org/en/latest/Options.html#reuse-port Linux >= 3.9?

Should http://uwsgi-docs.readthedocs.org/en/latest/Options.html#reuse-port
read "only on BSD or Linux >= 3.9"? Assuming this translates to


Daniel Holth
Tim Tisdall | 13 Apr 19:42 2015

HARAKIRI in threads and ugreen in uwsgi 2.1

Roberto mentioned that HARAKIRI isn't reliable right now in the 2.0.x
branch (for some concurrency models) but that it's fixed in the 2.1
version.  I understand that it'll accurately track the time each
thread/coroutine/whatever takes and then only HARAKIRI if one actually
takes too long.  However, does it still kill the whole worker process
or does it only kill the long running thread/coroutine/etc?
Tim Tisdall | 13 Apr 17:59 2015

best way of using logrotate

I was looking at post posts regarding using logrotate to rotate uwsgi
logs and was wondering what is the "best" way of doing it.

Using the "copytruncate" option of logrotate seems like a simple way
of doing it since it requires no change to uwsgi, but it seems that
it's possible to lose some logging during the transition.

The uwsgi option of "touch-logreopen" seems like a good method, but
what's the best file to use to monitor for a "touch"?  I was thinking
that maybe I could point it to the .log.1 file that logrotate would
copy the file over to.  Does the option work correctly if that file
isn't yet there?

Dorian Hoxha | 7 Apr 13:54 2015

Monitoring uwsgi in shared-hosting

Hi list,

I'm running uwsgi on a shared-hosting so I don't have access to upstart,systemd etc, and I want to start it if it crashes or when the server is restarted.

I currently have a cron-job running every 5 minutes, doing:

uwsgi --ini uwsgiconfig.ini

I see that the process-id inside the uwsgi.pid file changes everytime.
Is this ok?
My config:
http = :5000
wsgi-file = manage.py
callable = app
master = 1
processes = 2
static-map = /static=app/static
daemonize = uwsgi.log
pidfile = uwsgi.pid
single-interpreter = 1
Thank you
uWSGI mailing list
Jerry OELoo | 7 Apr 11:05 2015

How to gracefully restart uwsgi when running in daemon

I am running uwsgi in daemon mode,
In my configure file, it configed with daemonize

daemonize = /tmp/uwsgi_daemon.log

Then, I run uwsgi with command line: uwsgi --ini /xxx/uwsgi.ini
I found it will automatically running and I think it is in daemon status.

Now, I want to reload uwsgi gracefully when I modify some code.
uwsgi --reload ./uwsgi_master.pid

But I found that master pid in uwsgi_master.pid is not updated, I
think uwsgi is not restarted.
I think this maybe uwsgi run in daemon and will not handle HUP signal.
So when running in daemon, what is way to gracefully restart uwsgi.

Best Regards


Rejoice,I Desire!
chuck odonnell | 6 Apr 17:55 2015

on-demand multi-app setup


Hosting 200-300 WSGI apps. At any given time only 5-10 are active. The
goal is to have app load on demand, then die-on-idle. Active apps may
see a few hits a day, or a million hits a day. Others may sit for a
month with no traffic at all. Some apps use a unique virtualenv, so I
do not want them embedded in the same process. I would like each app
to be a process.

Basically we want to duplicate an on-demand FastCGI setup, but remove
fastcgi from the equation.

So far had luck implementing under nginx using:

  emperor = /usr/local/etc/uwsgi/sites
  emperor-on-demand-directory = /var/run/uwsgi

And for each file in /usr/local/etc/uwsgi/sites

  callable = app
  mount = /run/p1=proj.py
  chdir = /sites/p1
  manage-script-name = true
  workers = 20
  cheaper-initial = 1
  cheaper-step = 1
  idle = 10
  cheaper = 0
  die-on-idle = true
  fastcgi-socket = /var/run/uwsgi/p1.socket

However, I need this to work with Apache, but Apache/mod_proxy_uwsgi
does support dynamic Unix sockets.

So the question is, is there another approach I can take using
something like an emperor with a fastrouter that starts an app upon
regex match, and then lets the app die-on-idle after a time?

If I can do that, then I can configure Apache to route matching
requests to this single uWSGI process.

Suggestions welcome.

 Freebsd 10.1 Apache 2.4.12 uwsgi-2.0.10

Thank you.


Riccardo Magliocchetti | 5 Apr 23:48 2015

move away from atoi


atoi is deprecated in favour of strtol because its behaviour is undefined in 
case it cannot represent the string value as an integer.
So to avoid this i was thinking of introducing an uwsgi_atoi wrapper over strtol 
like the one below and convert atoi users to uwsgi_atoi. What do you think?

diff --git a/core/utils.c b/core/utils.c
index 0715b5b..123e501 100755
--- a/core/utils.c
+++ b/core/utils.c
 <at>  <at>  -4574,3 +4574,23  <at>  <at>  int uwsgi_versionsort(const struct dirent **da, const 
struct dirent **db) {
+int uwsgi_atoi(char *str) {
+       char *end;
+       long int num = strtol(str, &end, 10);
+       if (*end) {
+               uwsgi_error("uwsgi_atoi() unconverted string");
+               goto exit;
+       }
+       if (num == LONG_MIN || num < INT_MIN) {
+               uwsgi_error("uwsgi_atoi() underflow");
+               goto exit;
+       }
+       if (num == LONG_MAX || num > INT_MAX) {
+               uwsgi_error("uwsgi_atoi() overflow");
+               goto exit;
+       }
+       return (int) num;
+       exit(1);


Riccardo Magliocchetti
 <at> rmistaken
Roberto Bouza | 1 Apr 20:10 2015

Protobuf + HTTP


Just wondering if there is a way in uWSGI to get X amount of bytes from the packet that are protobuf, do some logic and then send the rest of the bytes as the HTTP packet.

Something like what the Netty Pipeline does.

Thank you.
uWSGI mailing list
Roberto De Ioris | 26 Mar 08:08 2015

experimental integration with rust

This is only a proof of concept, but should be a good starting point too



Roberto De Ioris
Murat Knecht | 26 Mar 04:02 2015

Default Log Format Explained?


could somebody tell me whether the default log format is explained
somewhere? I.e. the exact meanings of the numbers and other data in
lines such as:

    [pid: 596|app: 0|req: 24/72] () {50 vars in 1043
bytes} [Wed Jan 14 11:44:29 2015] POST /countries/ => generated 2 bytes
in 149 msecs (HTTP/1.1 200) 3 headers in 112 bytes (1 switches on core 0)

I can make some educated guesses, of course, but would rather not have to.

I have read the section in the documentation [1], which lists the
available options, and found the mail in the archive announcing the
log-format option [2] (cheers for that :) ). In the Git repository I
found the code where the log line is assembled [3], but since it does
not simply use the documented variables, it's not directly documenting
itself. Before I start digging in the code, did I miss the docs?

If not, I'd try to come up with a patch for the documentation. Does that
make sense?


[1] https://uwsgi-docs.readthedocs.org/en/latest/LogFormat.html
[2] http://lists.unbit.it/pipermail/uwsgi/2012-July/004463.html
[3] https://github.com/unbit/uwsgi/blob/master/core/logging.c#L715