uWSGI + Cherokee + web2py - a howto.

985 views
Skip to first unread message

Ivan P

unread,
Jan 14, 2010, 5:14:09 PM1/14/10
to web2py-users
Inspired by Phyo Arkar's howto on setting up web2py with Cherokee and
FCGI I tried the setup, but was somewhat unsatisfied with the fcgi
method and decided to try uWSGI. I am happy I did so, since it proved
to be real easy and uWSGI is a real powerhouse and deserves attention
of the whole python webdev community. On to the howto.

I. Compile from source and run the latest uWSGI, 0.9.3 in my case
(available here http://projects.unbit.it/uwsgi/wiki).
1. Download the source from and unzip.

2. To compile you must install packages python-dev and libxml2-dev (at
least thats what they are called on a debian-based system)

3. When compiling simply run pick a makefile which matches your OS and
python version and run something like "make -f Makefile.Linux.Py26".
This produces only one executable named uwsgi26, where 26 is my python
version. You can put it in /usr/local/bin.

5. To run it, you have two options:

5a) Create an xml file and call it, for example, config.xml. Put
something like this in it:
<uwsgi>
<pythonpath>/var/web2py/</pythonpath>
<app mountpoint="/">
<script>wsgihandler</script>
</app>
</uwsgi>
In this file "pythonpath" is where your web2py directory is and
"script" is the file you want to run, in this case its web2py's
"wsgihandler.py". Now run uWSGI like this, but replace "www-data" with
the owner of your web2py directory, if its the same as your current
user omit the sudo command:
sudo -u www-data uwsgi26 -s /tmp/uwsgi.sock -C -x config.xml
Why you need to change user is because web2py writes things (session
data for example) to disc during execution, so the uwsgi process,
which runs the web2py code, has to be the owner of the directories
that contain the framework. Note that uwsgi now opened a socket we
called "/tmp/uwsgi.sock" About other options consult the uwsgi manual
or "uwsgi -h".

5b) You can omit the xml file and pass all the info via command line,
doing that is easy, so consult the uwsgi docs :)


II. Setting up cherokee (0.99.37 in my case).
1. Install it, run cherokee-admin, go to localhost:9090

2. Open "Information Sources" and create a new one with these
parameters:
Nick: web2py
Connection: /tmp/uwsgi.sock
Interpreter: uwsgi26 -s /tmp/uwsgi.sock -C -x /path/to/config.xml
The interpreter line is why it is a good idea to have your web2py
source owned by www-data or the Cherokee server's user - when cherokee
runs it, you can be sure that owners of the sources and process match.
And of course put the correct path in.

3. Go to "Virtual Servers" and edit the default one, or you can create
a new one, but make sure you give it a domain name to avoid conflict
(not really sure what happens when they conflict).

4. Go to the "Behavior" section and edit the "Default" behavior.

5. Set the "Handler" to uWSGI and on the bottom set the information
source to "web2py"

6. Pick "Hard restart" from the dropdown on the left and click "Save".
TO PREVENT HEADACHE READ THIS: I seem to get inconsistent results with
these restarts, so if you're doing production it seems to me that one
should restart the server manualy (via /etc/init.d/cherokee restart,
that is). Or maybe I should RTFM.

6. Go to localhost and BAM! (or at least I hope its a bam). veeery
easy if all goes smooth.

"But wait, what about url rewriting?" was my thought, and this caused
much confusion, so I'll add a section on that.


III. Doing some redirection (I'll give few examples due to poor
knowledge of regex).
Lets redirect "localhost/" to "/myapp/cntrlr/index"
1. Go back to the "Behavior" section of your server.

2. Add a new rule and set it's type to "Regular Expression" and set
the regular expression to "^/$", this simply matches "localhost/" or
"localhost", nothing more, nothing less.

3. Go to the "Handler" section and set the rule to "Redirect" with
these parameters
Type: Internal
Regular Expression: (yes, blank)
Substitution: /myapp/cntrlr/index
The regular expression is blank because for this scenario we did all
the matching while defining a new behavior, you can combine the two in
creative ways.

That's about all. Your imagination should take care of the rest. I,
for example, put my static files separately from the framework by
creating a behavior that points to "/static" and picking "static
files" as the handler.
Thanks to Massimo DiPierro for web2py and Phyo Arkar for his cherokee
howto.
I'm not much of a writer so feel free to ask for clarifications.

Alex Fanjul

unread,
Jan 17, 2010, 3:01:56 PM1/17/10
to web...@googlegroups.com, Ivan P
Many thanks for your tutorial Ivan,
I'll give it a try... have you noticed any improvements with cherokee?
could you show us your "ab" benchmarks?

regards,
Alex F

P.S: try to make an slice in web2pyslices.com

El 14/01/2010 23:14, Ivan P escribi�:

--
Alejandro Fanjul Fdez.
alex....@gmail.com
www.mhproject.org

mdipierro

unread,
Jan 17, 2010, 3:13:54 PM1/17/10
to web2py-users
Have you tried if web2py file streaming works with cherokee?

On Jan 14, 4:14 pm, Ivan P <ivanv...@gmail.com> wrote:
> Inspired by Phyo Arkar's howto on setting up web2py with Cherokee and
> FCGI I tried the setup, but was somewhat unsatisfied with the fcgi
> method and decided to try uWSGI. I am happy I did so, since it proved
> to be real easy and uWSGI is a real powerhouse and deserves attention
> of the whole python webdev community. On to the howto.
>
> I. Compile from source and run the latest uWSGI, 0.9.3 in my case

> (available herehttp://projects.unbit.it/uwsgi/wiki).

Ivan P

unread,
Jan 17, 2010, 3:43:06 PM1/17/10
to web2py-users
mdipierro:
It works. Running http://localhost/admin/default/site all the CSS,
images and scripts are loaded fine.

Ivan P

unread,
Jan 17, 2010, 3:49:07 PM1/17/10
to web2py-users
Alex,
Actually, this is my first try at a production deployment, and I have
not set up another to test against. Is there a standard "ab" test that
is usually run for comparison in web2py community? In any case I ran
the following command with sqlite as the backend server (but doubt it
matters for this page) for the cherokee setup and the web2py builtin:
ab -n 1000 -c 5 url

===CHEROKEE results===

Server Software: Cherokee/0.99.39
Server Hostname: cparts.localhost
Server Port: 80

Document Path: /admin/default/index
Document Length: 5658 bytes

Concurrency Level: 5
Time taken for tests: 41.809 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 6031000 bytes
HTML transferred: 5658000 bytes
Requests per second: 23.92 [#/sec] (mean)
Time per request: 209.043 [ms] (mean)
Time per request: 41.809 [ms] (mean, across all concurrent
requests)
Transfer rate: 140.87 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 3
Processing: 65 208 11.3 208 283
Waiting: 65 208 11.3 208 283
Total: 69 209 11.2 208 283

Percentage of the requests served within a certain time (ms)
50% 208
66% 212
75% 214
80% 215
90% 219
95% 223
98% 235
99% 245
100% 283 (longest request)


===CHERRY PY results===

Server Software: CherryPy/3.2.0beta
Server Hostname: localhost
Server Port: 8000

Document Path: /welcome/default/index
Document Length: 6531 bytes

Concurrency Level: 5
Time taken for tests: 41.120 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 6892000 bytes
HTML transferred: 6531000 bytes
Requests per second: 24.32 [#/sec] (mean)
Time per request: 205.601 [ms] (mean)
Time per request: 41.120 [ms] (mean, across all concurrent
requests)
Transfer rate: 163.68 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 51 205 66.0 197 499
Waiting: 50 201 65.2 193 499
Total: 52 205 66.0 197 499

Percentage of the requests served within a certain time (ms)
50% 197
66% 222
75% 240
80% 254
90% 296
95% 328
98% 368
99% 402
100% 499 (longest request)

Sure, I'll make it a slice.

On Jan 17, 11:01 pm, Alex Fanjul <alex.fan...@gmail.com> wrote:
> Many thanks for your tutorial Ivan,
> I'll give it a try... have you noticed any improvements with cherokee?
> could you show us your "ab" benchmarks?
>
> regards,
> Alex F
>
> P.S: try to make an slice in web2pyslices.com
>
> El 14/01/2010 23:14, Ivan P escribi :
>
>
>
> > Inspired by Phyo Arkar's howto on setting up web2py with Cherokee and
> > FCGI I tried the setup, but was somewhat unsatisfied with the fcgi
> > method and decided to try uWSGI. I am happy I did so, since it proved
> > to be real easy and uWSGI is a real powerhouse and deserves attention
> > of the whole python webdev community. On to the howto.
>
> > I. Compile from source and run the latest uWSGI, 0.9.3 in my case

> > (available herehttp://projects.unbit.it/uwsgi/wiki).

> alex.fan...@gmail.comwww.mhproject.org

mdipierro

unread,
Jan 17, 2010, 4:11:04 PM1/17/10
to web2py-users
These tests basically measure lots of things at once and are dominated
by the database. If your are using sqlite, it locks the database
completely on every request so there is no concurrency.

I think we need a standard app for testing with various options:

1) db, no-db
2) 1,10,100 tables
3) view, no-view
4) compiled, not-compiler

mdipierro

unread,
Jan 17, 2010, 4:15:16 PM1/17/10
to web2py-users
In your benchmark, did you set migrate=False and bytecode compile the
app? Did you use Auth? How many additional tables?

Ivan P

unread,
Jan 18, 2010, 3:14:17 AM1/18/10
to web2py-users
Hmmm, you are right. But, since I was loading the index page of the
standard admin interface, that I have not compiled, I guess it is
whatever the admin defaults are (does admin even use a db?). Right?

mdipierro

unread,
Jan 18, 2010, 10:20:17 AM1/18/10
to web2py-users
You are right, the admin interface does not do db IO. From your test
it is slow. Not sure why that is.

> ...
>
> read more »

Ivan P

unread,
Jan 18, 2010, 11:15:59 AM1/18/10
to web2py-users
OK, I had some flaws in the last test that, I have realized, were
affecting the performance. For example uwsgi was outputing a whole lot
of data into gnome-terminal, which used much CPU. The new benchmark
with uwsgi running as a daemon:

Concurrency Level: 5
Time taken for tests: 22.585 seconds


Complete requests: 1000
Failed requests: 0
Write errors: 0

Total transferred: 6906000 bytes
HTML transferred: 6531000 bytes
Requests per second: 44.28 [#/sec] (mean)
Time per request: 112.923 [ms] (mean)
Time per request: 22.585 [ms] (mean, across all concurrent
requests)
Transfer rate: 298.62 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0

Processing: 65 113 6.2 111 164
Waiting: 65 112 6.2 111 164
Total: 66 113 6.2 111 164

Percentage of the requests served within a certain time (ms)

50% 111
66% 112
75% 113
80% 115
90% 119
95% 125
98% 133
99% 138
100% 164 (longest request)

ALSO, I tried running uwsgi with 4 worker processes by adding the
option "-p 4":

Concurrency Level: 5
Time taken for tests: 14.575 seconds


Complete requests: 1000
Failed requests: 0
Write errors: 0

Total transferred: 6906000 bytes
HTML transferred: 6531000 bytes
Requests per second: 68.61 [#/sec] (mean)
Time per request: 72.876 [ms] (mean)
Time per request: 14.575 [ms] (mean, across all concurrent
requests)
Transfer rate: 462.71 [Kbytes/sec] received

> ...
>
> read more »

mdipierro

unread,
Jan 18, 2010, 11:30:30 AM1/18/10
to web2py-users
This more like what I would expect. Is this bytecode compiled? It
makes a difference.

> ...
>
> read more »

Ivan P

unread,
Jan 18, 2010, 12:06:13 PM1/18/10
to web2py-users
No this is not bytecode compiled. What is odd is that I thought I
compiled admin yesterday to get great performance improvement, but now
compiling is not making a difference. I'm somewhat confused. So, I
cannot give much more data on this topic at the moment.
Why I chose Cherokee in the first place, though, was for the reported
ease of setup, since I have much work and little time. I think in that
domain it and uWSGI succeed. The setup was painless, it is flexible,
easy to tweak, uses next to no memory and seems reliable.

> ...
>
> read more »

Alex Fanjul

unread,
Jan 19, 2010, 8:53:42 PM1/19/10
to web...@googlegroups.com, Ivan P
And.... its Spanish!! http://es.wikipedia.org/wiki/Servidor_HTTP_Cherokee
Finally a Spanish international tool working fine :-D

by the way, it is shown as the best and fastest modern web server
http://www.cherokee-project.com/benchmarks.html

p.s: I'm Spaniard

El 18/01/2010 18:06, Ivan P escribi�:

>> read more �

Adi

unread,
Jan 27, 2010, 7:56:03 AM1/27/10
to web2py-users
Hi Ivan,

I followed this howto, and when I try to access the application I get
an internal error thrown by web2py:
Ticket issued: unknown

Any idea how to read contents of this ticket to debug?

On Jan 15, 3:14 am, Ivan P <ivanv...@gmail.com> wrote:
> Inspired by Phyo Arkar's howto on setting up web2py with Cherokee and
> FCGI I tried the setup, but was somewhat unsatisfied with the fcgi
> method and decided to try uWSGI. I am happy I did so, since it proved
> to be real easy and uWSGI is a real powerhouse and deserves attention
> of the whole python webdev community. On to the howto.
>
> I. Compile from source and run the latest uWSGI, 0.9.3 in my case

> (available herehttp://projects.unbit.it/uwsgi/wiki).

Thadeus Burgess

unread,
Jan 27, 2010, 10:33:49 AM1/27/10
to web...@googlegroups.com
open the file on the filesystem

web2py/applications/myapp/errors/<traceback_id>

its a python pickle object, but you can still read good enough opening it in a text editor.

-Thadeus




--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.


Ivan P

unread,
Feb 5, 2010, 5:45:54 AM2/5/10
to web2py-users
Sorry for the delayed response.
I think that usually means that your permissions are not set. Make
sure that uwsgi is running under the same user that owns your web2py
directory. The error is unknown cause web2py cannot open the error
file, because it cannot write it to disc.

Thadeus Burgess

unread,
Feb 22, 2010, 2:40:16 PM2/22/10
to web...@googlegroups.com
How do you tell what user cherokee gets executed as when the server boots up?

In my typical installation I have a generic user account (like
"servant") that everything server related exists in this home
directory, and it owns everything. With Apache I have to chown/mod the
files so that www-data can read them.

I need to use a user account instead of www-data since mercurial is involved.

As far as static file streaming, does cherokee intercept web2py file serving?

Is there a way to tell cherokee to serve all requests to the "static"
folder without even going through web2py?

-Thadeus

GrayMatterComputing

unread,
Feb 24, 2010, 1:37:05 AM2/24/10
to web2py-users
Open the Cherokee Admin -> General -> Server Permissions. There you
are :)

Cherokee will respond in the priority order you have set for the
virtual servers and behaviors. It will evaluate only the first rule in
the list that matches. For example, if you had a static content rule
for the directory "/static" and web2py was the default, a request for
"example.com/stuff" would pass to web2py, while "example.com/static/
stuff" would be evaluated by the static content rule.

On Feb 22, 2:40 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
> How do you tell what usercherokeegets executed as when the server boots up?


>
> In my typical installation I have a generic user account (like
> "servant") that everything server related exists in this home
> directory, and it owns everything. With Apache I have to chown/mod the
> files so that www-data can read them.
>
> I need to use a user account instead of www-data since mercurial is involved.
>

> As far as static file streaming, doescherokeeintercept web2py file serving?
>
> Is there a way to tellcherokeeto serve all requests to the "static"


> folder without even going through web2py?
>
> -Thadeus
>

> On Fri, Feb 5, 2010 at 4:45 AM, Ivan P <ivanv...@gmail.com> wrote:
> > Sorry for the delayed response.
> > I think that usually means that your permissions are not set. Make

> > sure thatuwsgiis running under the same user that owns your web2py


> > directory. The error is unknown cause web2py cannot open the error
> > file, because it cannot write it to disc.
>
> > On Jan 27, 3:56 pm, Adi <aditya.sa...@gmail.com> wrote:
> >> Hi Ivan,
>
> >> I followed this howto, and when I try to access the application I get
> >> an internal error thrown by web2py:
> >> Ticket issued: unknown
>
> >> Any idea how to read contents of this ticket to debug?
>
> >> On Jan 15, 3:14 am, Ivan P <ivanv...@gmail.com> wrote:
>
> >> > Inspired by Phyo Arkar's howto on setting up web2py withCherokeeand
> >> > FCGI I tried the setup, but was somewhat unsatisfied with the fcgi

> >> > method and decided to tryuWSGI. I am happy I did so, since it proved
> >> > to be real easy anduWSGIis a real powerhouse and deserves attention


> >> > of the whole python webdev community. On to the howto.
>

> >> > I. Compile from source and run the latestuWSGI, 0.9.3 in my case


> >> > (available herehttp://projects.unbit.it/uwsgi/wiki).
> >> > 1. Download the source from and unzip.
>
> >> > 2. To compile you must install packages python-dev and libxml2-dev (at
> >> > least thats what they are called on a debian-based system)
>
> >> > 3. When compiling simply run pick a makefile which matches your OS and
> >> > python version and run something like "make -f Makefile.Linux.Py26".
> >> > This produces only one executable named uwsgi26, where 26 is my python
> >> > version. You can put it in /usr/local/bin.
>
> >> > 5. To run it, you have two options:
>
> >> > 5a) Create an xml file and call it, for example, config.xml. Put
> >> > something like this in it:
> >> > <uwsgi>
> >> >     <pythonpath>/var/web2py/</pythonpath>
> >> >     <app mountpoint="/">
> >> >     <script>wsgihandler</script>
> >> >     </app>
> >> > </uwsgi>
> >> > In this file "pythonpath" is where your web2py directory is and
> >> > "script" is the file you want to run, in this case its web2py's

> >> > "wsgihandler.py". Now runuWSGIlike this, but replace "www-data" with


> >> > the owner of your web2py directory, if its the same as your current
> >> > user omit the sudo command:
> >> > sudo -u www-data uwsgi26 -s /tmp/uwsgi.sock -C -x config.xml
> >> > Why you need to change user is because web2py writes things (session
> >> > data for example) to disc during execution, so theuwsgiprocess,
> >> > which runs the web2py code, has to be the owner of the directories

> >> > that contain the framework. Note thatuwsginow opened a socket we


> >> > called "/tmp/uwsgi.sock" About other options consult theuwsgimanual

> >> > or "uwsgi-h".


>
> >> > 5b) You can omit the xml file and pass all the info via command line,
> >> > doing that is easy, so consult theuwsgidocs :)
>

> >> > II. Setting upcherokee(0.99.37 in my case).
> >> > 1. Install it, runcherokee-admin, go to localhost:9090


>
> >> > 2. Open "Information Sources" and create a new one with these
> >> > parameters:
> >> > Nick: web2py
> >> > Connection: /tmp/uwsgi.sock
> >> > Interpreter: uwsgi26 -s /tmp/uwsgi.sock -C -x /path/to/config.xml
> >> > The interpreter line is why it is a good idea to have your web2py
> >> > source owned by www-data or theCherokeeserver's user - whencherokee
> >> > runs it, you can be sure that owners of the sources and process match.
> >> > And of  course put the correct path in.
>
> >> > 3. Go to "Virtual Servers" and edit the default one, or you can create
> >> > a new one, but make sure you give it a domain name to avoid conflict
> >> > (not really sure what happens when they conflict).
>
> >> > 4. Go to the "Behavior" section and edit the "Default" behavior.
>

> >> > 5. Set the "Handler" touWSGIand on the bottom set the information

Thadeus

unread,
Feb 27, 2010, 1:10:48 AM2/27/10
to web2py-users
What if I want

example.com/app/static
example.com/app2/static

What exact rule do I use for this situation?

On Feb 24, 12:37 am, GrayMatterComputing <battledi...@gmail.com>
wrote:
> Open theCherokeeAdmin -> General -> Server Permissions. There you
> are :)
>
> Cherokeewill respond in the priority order you have set for the

Ivan P

unread,
Mar 2, 2010, 1:29:37 AM3/2/10
to web2py-users
Could you elaborate? You want those two rules to point to a static
folder?
If that is the case, you would probably add a new regex rule with
something like "^/app/static$", and add a "static" handler to that
rule, and for the handler just pick the directory where the static
files are.

Ivan P

unread,
Mar 2, 2010, 1:35:10 AM3/2/10
to web2py-users
Make that rule "^/app/static"

muybay

unread,
Apr 18, 2010, 2:13:34 AM4/18/10
to web2py-users
Thanks for this great guide Ivan, you saved me hours of configuration
time and I learned a lot.

pbreit

unread,
Dec 17, 2010, 7:35:59 PM12/17/10
to web...@googlegroups.com
I added an install script as a slice for setting up Cherokee, uWSGI and Web2py on a new Ubuntu 10.04 instance: http://web2pyslices.com/main/slices/take_slice/110

It's pretty similar to Gray Matter's instructions. I'll add SSL to it when I figure that out.

pbreit

unread,
Dec 17, 2010, 7:37:32 PM12/17/10
to web...@googlegroups.com
Oops: also very similar to Ivan's instructions.

pbreit

unread,
Dec 23, 2010, 1:16:35 AM12/23/10
to web...@googlegroups.com
I added instructions for SSL:

Seems to work OK.

Leopold

unread,
Jun 7, 2012, 2:50:06 PM6/7/12
to web...@googlegroups.com
Hello everyone, I'm in need of help to get this configuration (ubuntu + cherokee + web2py + uwsgi) running.
I used a very similar how to on this (this happened many months ago) and everything worked perfectly.

When I followed the instructions I had an ubuntu version with python 2.6 but when I decided to upgrade to ubuntu 12.04 (python 2.7) the problem started. Initially the problem was the 503 Service Unavailable message and by looking at the logs it was obvious the change in python version was responsible for this since uwsgi was saying libpython2.6.so.1.0 missing or something like that. So I reinstalled the latest uwsgi built with python 2.7 and the 503 error went away. However I still couldn't get my web2py app to show, I now get:

uWSGI Error

Python application not found

I searched all over for this but I can't find how to fix it. I'm posting the cherokee error log and the uwsgi config file hoping you can help me.


# cat /var/log/cherokee/cherokee.error
[uWSGI] parsing config file /var/web2py/config.xml
[WARNING] option "app" is deprecated: use the more advanced "mount" option
*** Starting uWSGI 1.2.3 (32bit) on [Thu Jun  7 11:19:17 2012] ***
compiled with version: 4.6.3 on 07 June 2012 09:24:31
detected number of CPU cores: 1
current working directory: /
detected binary path: /usr/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
uwsgi socket 0 bound to TCP address 127.0.0.1:40890 fd 4
Python version: 2.7.3 (default, Apr 20 2012, 23:06:40)  [GCC 4.6.3]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x896f8a0
your server socket listen backlog is limited to 100 connections
*** Operational MODE: single process ***
added /var/web2py/ to pythonpath.
mounting wsgihandler on /
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 7903, cores: 1)
[pid: 7903|app: -1|req: -1/1] 192.1.209.75 () {54 vars in 875 bytes} [Thu Jun  7 11:19:17 2012] GET /favicon.ico => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 7903|app: -1|req: -1/2] 192.1.209.75 () {56 vars in 922 bytes} [Thu Jun  7 11:20:01 2012] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 7903|app: -1|req: -1/3] 192.1.209.75 () {54 vars in 875 bytes} [Thu Jun  7 11:20:01 2012] GET /favicon.ico => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 7903|app: -1|req: -1/4] 192.1.209.75 () {54 vars in 891 bytes} [Thu Jun  7 11:20:09 2012] GET / => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 7903|app: -1|req: -1/5] 192.1.209.75 () {54 vars in 875 bytes} [Thu Jun  7 11:20:09 2012] GET /favicon.ico => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)


# cat /var/web2py/config.xml

<uwsgi>
    <pythonpath>/var/web2py/</pythonpath>
    <app mountpoint="/">
    <script>wsgihandler</script>
    </app>
</uwsgi>

cherokee interpreter:
/usr/bin/uwsgi -s 127.0.0.1:40890 -x /var/web2py/config.xml


Thanks in advance.

pbreit

unread,
Jun 7, 2012, 3:07:03 PM6/7/12
to web...@googlegroups.com
Are you committed to Cherokee? I would advise against that since development has stalled/stopped and instead consider Apache or Nginx. If Nginx, web2py includes a setup script:

You can either run the script as-is or, a better idea is to just manually run each step so you get an understanding for what's going on and can fix any problems.

Leopold

unread,
Jun 7, 2012, 3:27:11 PM6/7/12
to web...@googlegroups.com
I am not committed to cherokee and if this goes unsolved then I would be forced to choose another webserver, Apache seems overkill since my app is only used by intranet users; I am taking a look at Nginx at the moment. Still, I'm a bit reluctant to just forget about it since it worked wonderfully until now and I have a feeling it may be just a minor thing but I just cant find what it is.

Anyway thanks for the suggestion but in the meantime if somebody knows how to fix this please post, even it is just for future reference...

Vasile Ermicioi

unread,
Jun 8, 2012, 4:09:51 AM6/8/12
to web...@googlegroups.com
I said many times before: 

use just uwsgi - it has a fast built in webserver :)

Leopold

unread,
Jun 28, 2012, 1:14:05 PM6/28/12
to web...@googlegroups.com

Hi. First of all, sorry for not posting back, I had some unplanned issues.
Anyway, I tried the Ngnix approach (http://code.google.com/p/web2py/source/browse/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh) and long story short it didn't work either; same result as it did with cherokee on web browser:


uWSGI Error

Python application not found

So this is beyond the web server, something is wrong with uwsgi configuration but no error is displayed at uwsgi log:

# cat /var/log/uwsgi/app/web2py.log
Thu Jun 28 09:47:44 2012 - *** Starting uWSGI 1.2.3 (32bit) on [Thu Jun 28 09:47:44 2012] ***
Thu Jun 28 09:47:44 2012 - compiled with version: 4.6.3 on 07 June 2012 09:24:31
Thu Jun 28 09:47:44 2012 - detected number of CPU cores: 1
Thu Jun 28 09:47:44 2012 - current working directory: /
Thu Jun 28 09:47:44 2012 - writing pidfile to /run/uwsgi/app/web2py/pid
Thu Jun 28 09:47:44 2012 - detected binary path: /usr/bin/uwsgi
Thu Jun 28 09:47:44 2012 - setgid() to 33
Thu Jun 28 09:47:44 2012 - setuid() to 33
Thu Jun 28 09:47:44 2012 - your memory page size is 4096 bytes
Thu Jun 28 09:47:44 2012 - detected max file descriptor number: 1024
Thu Jun 28 09:47:44 2012 - lock engine: pthread robust mutexes
Thu Jun 28 09:47:44 2012 - uwsgi socket 0 bound to UNIX address /run/uwsgi/app/web2py/socket fd 3
Thu Jun 28 09:47:44 2012 - uwsgi socket 1 bound to TCP address 127.0.0.1:9001 fd 5
Thu Jun 28 09:47:44 2012 - Python version: 2.7.3 (default, Apr 20 2012, 23:06:40)  [GCC 4.6.3]
Thu Jun 28 09:47:44 2012 - *** Python threads support is disabled. You can enable it with --enable-threads ***
Thu Jun 28 09:47:44 2012 - Python main interpreter initialized at 0x8899410
Thu Jun 28 09:47:44 2012 - your server socket listen backlog is limited to 100 connections
Thu Jun 28 09:47:44 2012 - *** Operational MODE: preforking ***
Thu Jun 28 09:47:44 2012 - added /home/www-data/web2py/ to pythonpath.
Thu Jun 28 09:47:44 2012 - mounting wsgihandler on /
Thu Jun 28 09:47:44 2012 - *** no app loaded. going in full dynamic mode ***
Thu Jun 28 09:47:44 2012 - *** uWSGI is running in multiple interpreter mode ***
Thu Jun 28 09:47:44 2012 - spawned uWSGI master process (pid: 6429)
Thu Jun 28 09:47:44 2012 - spawned uWSGI worker 1 (pid: 6437, cores: 1)
Thu Jun 28 09:47:44 2012 - spawned uWSGI worker 2 (pid: 6438, cores: 1)


This is what happens when I try to restart uwsgi:

# /etc/init.d/uwsgi restart
 * Restarting app server(s) uwsgi
[uWSGI] getting INI configuration from /usr/share/uwsgi/conf/default.ini
[uWSGI] parsing config file /etc/uwsgi/apps-enabled/web2py.xml
./python_plugin.so: cannot open shared object file: No such file or directory
Thu Jun 28 10:07:33 2012 - [WARNING] option "app" is deprecated: use the more advanced "mount" option


when in fact python_plugin.so does exist:
# list /usr/lib/uwsgi/plugins
total 128K
lrwxrwxrwx 1 root root   37 Jun 28 09:22 python_plugin.so -> /etc/alternatives/uwsgi-plugin-python
-rw-r--r-- 1 root root 127K Feb 20 02:08 python27_plugin.so

Any ideas?
Thanks for your time

pbreit

unread,
Jul 1, 2012, 11:38:18 PM7/1/12
to web...@googlegroups.com
It's pointing to: /etc/alternatives/uwsgi-plugin-python

Is there anything there?

Are the permissions OK? I run my Ubuntu server under www-data:www-data.

Leopold

unread,
Jul 2, 2012, 1:10:04 PM7/2/12
to web...@googlegroups.com
listing of directory:

% list /etc/alternatives/uwsgi*
lrwxrwxrwx 1 root root 19 Jun 28 09:22 /etc/alternatives/uwsgi -> /usr/bin/uwsgi-core
lrwxrwxrwx 1 root root 35 Jun 28 09:22 /etc/alternatives/uwsgi.1.gz -> /usr/share/man/man1/uwsgi-core.1.gz
lrwxrwxrwx 1 root root 19 Jun 28 09:22 /etc/alternatives/uwsgi_python -> /usr/bin/uwsgi-core
lrwxrwxrwx 1 root root 39 Jun 28 09:22 /etc/alternatives/uwsgi_python.1.gz -> /usr/share/man/man1/uwsgi_python27.1.gz
lrwxrwxrwx 1 root root 41 Jun 28 09:22 /etc/alternatives/uwsgi-plugin-python -> /usr/lib/uwsgi/plugins/python27_plugin.so

% list /usr/lib/uwsgi/plugins/
total 128K
lrwxrwxrwx 1 root root   37 Jun 28 09:22 python_plugin.so -> /etc/alternatives/uwsgi-plugin-python
-rw-r--r-- 1 root root 127K Feb 20 02:08 python27_plugin.so

I also run the webserver under user www-data but I have not made any changes to files or directory owners. Web2py folder and everything inside is property of www-data
% list /home/www-data
total 4.0K
drwxr-xr-x 8 www-data www-data 4.0K Jun 28 09:26 web2py

I tried to set up another (completely separate) server doing a fresh install of everything (including ubuntu 12.04 from scratch) and I had no problems; it worked fine with nginx, so somehow the uwsgi configuration got screwed during the dist-upgrade from 11.10.

Thanks.
Reply all
Reply to author
Forward
0 new messages