Beta testing for mod_wsgi

Hi.

I’m releasing the 0.0.6 version of the WSGI module for nginx.

I would like to have it tested (at least compilation) on all systems
supported by nginx.

I have tested it on my PC (Debian Etch i386), and on FreeBSD and OpenBSD
(using qemu).

The Python version I’m using is 2.4, but I have done some tests with 2.3
and 2.5.

I have tried to install FreeBSD and Open Solaris on qemu, but without
success.

64 bits system need testing, too (I have a 64bit CPU, but I have choosen
to install the 32bit Debian version).

I will appreciate any help, thanks.

In the next version I will implement some extensions to WSGI, then
mod_wsgi module should stabilize (I hope).

Manlio P.

On Sun, Jan 06, 2008 at 03:55:57PM +0100, Manlio P. wrote:

In the next version I will implement some extensions to WSGI, then mod_wsgi
module should stabilize (I hope).

Maybe add some links?

The wiki page: http://wiki.codemongers.com/NginxNgxWSGIModule

The Mercurial stuff? http://hg.mperillo.ath.cx/nginx/mod_wsgi/

Should we be testing
http://hg.mperillo.ath.cx/nginx/mod_wsgi/archive/tip.tar.gz, or is there
a separate 0.0.6 tarball?

The easier it is, the more testers you will get :slight_smile:

Darrin Chandler ha scritto:

and 2.5.

In the next version I will implement some extensions to WSGI, then mod_wsgi
module should stabilize (I hope).

Maybe add some links?

Ops… :).

The wiki page: http://wiki.codemongers.com/NginxNgxWSGIModule

The Mercurial stuff? http://hg.mperillo.ath.cx/nginx/mod_wsgi/

Should we be testing
http://hg.mperillo.ath.cx/nginx/mod_wsgi/archive/tip.tar.gz, or is there
a separate 0.0.6 tarball?

It is all explained in the wiki page: I have just updated it.
Let me know if something is not clear.
Be aware that the nginx version to use is the latest in the stable
branch (0.5.34); other versions of nginx may require to apply some
patches.

More informations about patches is in:
http://hg.mperillo.ath.cx/nginx/mod_wsgi/file/tip/patches/README

There is no separate tarball, sorry, so you should use the tip using
Mercurial archive support:
http://hg.mperillo.ath.cx/nginx/mod_wsgi/archive/tip.tar.gz

In future (when I will release the 0.1 version) I will take some
decisions for a better hosting.

The easier it is, the more testers you will get :slight_smile:

Right, thanks!

Regards Manlio P.

El Sun, 06 Jan 2008 15:55:57 +0100
Manlio P. [email protected] escribió:

I’m releasing the 0.0.6 version of the WSGI module for nginx.

This is great news =)

64 bits system need testing, too (I have a 64bit CPU, but I have
choosen to install the 32bit Debian version).

I am using a 64-bit install Gentoo Linux (x86-64, Intel Core2 Duo)
I have built successfully nginx 0.6.25 with mod_wsgi without
compilation warnings (gcc 4.2.2). Nginx without using mod_wsgi
features works as expected, I will be done some testing in the next 2-3
days.

Best regards,

Adrian P. ha scritto:

I am using a 64-bit install Gentoo Linux (x86-64, Intel Core2 Duo)
I have built successfully nginx 0.6.25 with mod_wsgi without
compilation warnings (gcc 4.2.2). Nginx without using mod_wsgi
features works as expected, I will be done some testing in the next 2-3
days.

Thanks, this is a good news!
Now only a basic test on Solaris is missing.

Best regards,

Regards Manlio P.

On Sat, 12 Jan 2008 21:37:48 +0100
Manlio P. [email protected] wrote:

Now only a basic test on Solaris is missing.

I can confirm it compiles on both Solaris SPARC and x86. The libraries I
use from blastwave are for 32 bit, though, so I didn’t test compiling
for 64 bit. I also just saw that it compiled properly; I didn’t test
any actual running.

Compiled with Sun Studio 11 on the SPARC machine, and Sun Studio 12 on
the x86 one, as shown below (formatting might be a little wonky).

$ uname -a
SunOS foo 5.10 Generic_120011-14 sun4u sparc
SUNW,Sun-Fire-V240
$ ./objs/nginx -V
nginx version: nginx/0.5.35
built by Sun C 5.8 Patch 121015-04 2007/01/10
configure arguments: --prefix=/etc/nginx
–conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx
–pid-path=/var/run/nginx.pid --lock-path=/var/tmp/nginx/nginx.lock
–http-client-body-temp-path=/var/tmp/nginx/client_body_temp
–http-proxy-temp-path=/var/tmp/nginx/proxy_temp
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp
–http-log-path=/var/log/nginx-access.log
–error-log-path=/var/log/nginx-error.log
–with-cc-opt=-I/opt/csw/include --with-ld-opt=-L/opt/csw/lib
-R/opt/csw/lib --with-http_ssl_module --with-http_stub_status_module
–with-imap --with-imap_ssl_module
–add-module=/local/scratch/nginx/mod_wsgi

$ uname -a
SunOS bar 5.10 Generic_120012-14 i86pc i386 i86pc
$ ./objs/nginx -V
nginx version: nginx/0.5.35
built by Sun C 5.9 SunOS_i386 Patch 124868-01 2007/07/12
configure arguments: --prefix=/etc/nginx
–conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin/nginx
–pid-path=/var/run/nginx.pid --lock-path=/var/tmp/nginx/nginx.lock
–http-client-body-temp-path=/var/tmp/nginx/client_body_temp
–http-proxy-temp-path=/var/tmp/nginx/proxy_temp
–http-fastcgi-temp-path=/var/tmp/nginx/fastcgi_temp
–http-log-path=/var/log/nginx-access.log
–error-log-path=/var/log/nginx-error.log
–with-cc-opt=-I/opt/csw/include --with-ld-opt=-L/opt/csw/lib
-R/opt/csw/lib --with-http_ssl_module --with-http_stub_status_module
–with-imap --with-imap_ssl_module
–add-module=/local/scratch/nginx/mod_wsgi

El Sat, 12 Jan 2008 21:37:48 +0100
Manlio P. [email protected] escribió:

Now only a basic test on Solaris is missing.
So I suppose my last test will be good news, too: I have successfully
built the thing in my old iBook (32-bit PowerPC G3) with no warnings.
Details: Gentoo Linux, kernel 2.6.21, Nginx 0.6.25, gcc 4.1.2.

I made myself a modified ebuild which optionally adds the WSGI module
and my own module (they are two USE-flags). For us Gentoo users:
http://foobar.homeunix.org/hario-overlay/www-servers/nginx/

Regards,

-Adrian

Adrian P. ha scritto:

Thanks, this is a good news!
Now only a basic test on Solaris is missing.

So I suppose my last test will be good news, too: I have successfully
built the thing in my old iBook (32-bit PowerPC G3) with no warnings.
Details: Gentoo Linux, kernel 2.6.21, Nginx 0.6.25, gcc 4.1.2.

Ok, now it seems that the compilation is ok on all systems supported by
nginx.

NetBSD is still missing, I have tried to install it on a qemu instance,
but the virtual network card is not recognized.

In future I will try to add some automated tests.

I made myself a modified ebuild which optionally adds the WSGI module
and my own module (they are two USE-flags). For us Gentoo users:
http://foobar.homeunix.org/hario-overlay/www-servers/nginx/

Regards,

-Adrian

Thanks Manlio P.

Andrew Deason ha scritto:

Compiled with Sun Studio 11 on the SPARC machine, and Sun Studio 12 on
the x86 one, as shown below (formatting might be a little wonky).

Thanks for the report!

[…]

Manlio P.

Now with WSGI-enabled Bazaar repository, hehe:

El Mon, 14 Jan 2008 03:49:27 +0100
Adrian P. [email protected] escribió:

  auth_basic_user_file /tmp/test/passwd;
  wsgi_pass /tmp/test/run.wsgi;
}
  location /bzr {
    wsgi_pass /tmp/test/bzrsmart.wsgi;
  }
location / {
  wsgi_pass /tmp/test/run.wsgi;
}

}

Next test will be Bazaar’s smart-server over HTTP, as it is also a
WSGI application.

Contents of “bzrsmart.wsgi”:

from bzrlib.transport.http import wsgi
application = wsgi.make_app(root=“/tmp/test”,
prefix=“/”, path_var=“REQUEST_URI”,
readonly=True)

Do “mkdir /tmp/test/bzr” and put some branches on it… you are done
and the thing works as expected =)

Maybe I will switch from Apache to Nginx at home in the next days, as I
use Trac and Bazaar for tracking my stuff…

Best regards, hope you find this this report useful,

http://hg.mperillo.ath.cx/nginx/mod_wsgi/archive/tip.tar.gz
how to use this with nginx
should this tar file be unzipped into an nginx latest folder and
compiled?
instructions please

El Sat, 12 Jan 2008 20:50:47 +0100
Adrian P. [email protected] escribió:

Nginx without using mod_wsgi features works as expected, I will be
done some testing in the next 2-3 days.

Rewarding this, it looks like all test scripts included with mod_wsgi
run without problems in my laptop (x86-64, Intel Core2, Gentoo Linux).

The shocking news: I have been able of running Trac 0.11 beta1 with
mod_wsgi! The configuration snippets looks like this:

server {
listen 127.0.0.1;
server_name localhost;

root /var/www/localhost/htdocs;

include wsgi_vars;

location /login {
  auth_basic "Trac";
  auth_basic_user_file /tmp/test/passwd;
  wsgi_pass /tmp/test/run.wsgi;
}
location / {
  wsgi_pass /tmp/test/run.wsgi;
}

}

The idea of adding an extra “/login” location for authentication was
taken from TracCgi – The Trac Project

The “run.wsgi” file contents are as follows (inspiration taken from
TracModWSGI – The Trac Project):

import os, trac.web.main
os.environ[“TRAC_ENV”] = “/tmp/test”
os.environ[“PYTHON_EGG_CACHE”] = “/tmp/test/eggs”
application = trac.web.main.dispatch_request

Next test will be Bazaar’s smart-server over HTTP, as it is also a WSGI
application.

Manlio you rock! I am getting very excited about this stuff!

El Sun, 13 Jan 2008 19:33:49 -0800
[email protected] escribió:

http://hg.mperillo.ath.cx/nginx/mod_wsgi/archive/tip.tar.gz
how to use this with nginx
should this tar file be unzipped into an nginx latest folder and
compiled? instructions please

For example, if you want to build nginx 0.6.x with the latest mod_wsgi,
get the packages and unpack them:

cd /tmp

wget http://hg.mperillo.ath.cx/nginx/mod_wsgi/archive/tip.tar.gz

wget http://sysoev.ru/nginx/nginx-0.6.25.tar.gz

tar -xfz tip.tar.gz

tar -xfz nginx-0.6.25.tar.gz

As we are using Nginx 0.6 we must patch mod_wsgi sources:

( cd mod_wsgi-* && patch -p1 < patches/nginx-0.6.x.patch )

Finally, configure and build Nginx, the trick is the “–add-module”
flag to the configure script:

cd nginx-0.6.25

./configure --add-module=…/mod_wsgi-*

make && make install

You’ll end up having a fresh Nginx installation in /usr/local :wink:

El Sun, 13 Jan 2008 19:46:02 -0800
[email protected] escribió:

Please note that using Trac via CGI is significantly slower than any
other deployment method, such as
mod_pythonhttp://trac.edgewall.org/wiki/TracModPythonor
FastCGI http://trac.edgewall.org/wiki/TracFastCgi.

I am aware CGI is the slower method :wink:

I used Manlio’s mod_wsgi to serve a Trac instance (which is similar to
mod_python in the sense that it embeds a Python interpreter into the
webserver.)

Regards,

Please note that using Trac via CGI is significantly slower than any
other
deployment method, such as
mod_pythonhttp://trac.edgewall.org/wiki/TracModPythonor
FastCGI http://trac.edgewall.org/wiki/TracFastCgi.

Adrian P. ha scritto:

El Sat, 12 Jan 2008 20:50:47 +0100
Adrian P. [email protected] escribió:

Nginx without using mod_wsgi features works as expected, I will be
done some testing in the next 2-3 days.

Rewarding this, it looks like all test scripts included with mod_wsgi
run without problems in my laptop (x86-64, Intel Core2, Gentoo Linux).

Ok, thanks

The idea of adding an extra “/login” location for authentication was
taken from TracCgi – The Trac Project

The “run.wsgi” file contents are as follows (inspiration taken from
TracModWSGI – The Trac Project):

import os, trac.web.main
os.environ[“TRAC_ENV”] = “/tmp/test”
os.environ[“PYTHON_EGG_CACHE”] = “/tmp/test/eggs”
application = trac.web.main.dispatch_request

Note that here you do not need an extra script: you can just do in nginx
configuration:

env PYTHON_EGG_CACHE /tmp/test/eggs

location / {
wsgi_param trac.env_path /tmp/test
wsgi_pass /path/to/trac.web.main dispatch_request;
}

Next test will be Bazaar’s smart-server over HTTP, as it is also a WSGI
application.

Manlio you rock! I am getting very excited about this stuff!

Thanks, but it is all merit of nginx.

Manlio P.

Adrian P. ha scritto:

By the way: does Bazaar uses the write callable?

Best regards, hope you find this this report useful,

Regards Manlio P.

[mark@db264282 ~/work]$ nginx -c infrastructure/nginx_trac_modwsgi.conf
2008/01/15 02:24:10 [emerg] 25298#0: glob() “/opt/local/conf/wsgi_vars”
failed (2: No such file or directory) in
infrastructure/nginx_trac_modwsgi.conf:39
Adrian how to fix this

El Mon, 14 Jan 2008 11:33:19 +0100
Manlio P. [email protected] escribió:

By the way: does Bazaar uses the write callable?

I took a peek at bzrlib/transport/http/wsgi.py, and it uses a StringIO
(about line 115) to assemble the output. It does not use the write
callable.

Have a nice day,


$ cat /usr/include/sys/errno.h
#define EPERM 1 /* Operation not permitted /
#define ENOENT 2 /
No such file or directory /
#define ESRCH 3 /
No such process /
#define EINTR 4 /
Interrupted system call /
[…]
#define EMACS 666 /
Editor Too Large */
$

nginx -c infrastructure/nginx_trac_modwsgi.conf
2008/01/15 02:31:40 [emerg] 25478#0: glob() “/opt/local/conf/wsgi_vars”
failed (2: No such file or directory) in
infrastructure/nginx_trac_modwsgi.conf:40
[mark@db264282 ~/work]$ cd /opt/local/wsgi_temp/
-bash: cd: /opt/local/wsgi_temp/: Permission denied
adrian this is the error on using the conf file for trac nginx