Niphlod,

Thanks again. Is uwsgi faster/safer? Anyhow, I tried doing what you said. 
But instead of following the difficult instructions in the web2py book, I 
used the instructions in uwsgi documentation. I have attached three files:

(1) My nginx configuration. (mysite_nginxconf.com)
(2) uwsgi configuration (wsgiconf.ini)
(3) The console output when I run uwsgi directly (now there is some output 
and it gives some idea about the error). When I try to visit the site I get 
"Internal server error" message. (uwsgi_consoleLog.txt)

One problem I see is that ImportError: No module named wsgihandler

But I see wsgihandler.py in the web2py/handlers folder. Should it not read 
it from there? Do I have to install it separately, or give path to it 
somehow?

Really appreciate your help. Difficulty to deploying python apps is 
frustrating and despite all the great things web2py offers, the difficulty 
in deployment might otherwise require me to use something else.




On Tuesday, October 22, 2013 5:41:38 PM UTC-4, Niphlod wrote:
>
> low performances vs running web2py on uwsgi.
>
> PS: try running uwsgi directly pointing to that config file (i.e. no 
> emperor mode with upstart, so you get a chance to see any logged error that 
> may pop up)
>
> On Tuesday, October 22, 2013 10:15:16 PM UTC+2, curiouslearn wrote:
>>
>> While some helpful soul helps me understand how to setup web2py to work 
>> with nginx and uwsgi, I had another question. 
>>
>> Is there anything wrong, or problematic in using the following for 
>> deployment
>>
>> Run web2py using 
>>
>> python web2py.py -a mypasswd -i 0.0.0.0 -p 9001
>>
>> and then use nginx to direct traffic from http://mydomain.com to this 
>> running instance. 
>>
>> This seems an easy way to do it. What I am risking by doing this?
>>
>> Thank you.
>>
>> On Tuesday, October 22, 2013 3:28:21 PM UTC-4, curiouslearn wrote:
>>>
>>> Niphlod,
>>>
>>> Thanks for getting back to me. There is no file that has uwsgi-emperor 
>>> in its name in /var/log/upstart.
>>>
>>> Anything else I can do to find what is the problem? 
>>>
>>> On Tuesday, October 22, 2013 1:03:37 PM UTC-4, Niphlod wrote:
>>>>
>>>> every upstart job logs something into 
>>>>  /var/log/upstart/name_of_the_service.log
>>>>
>>>> check if you have something on /var/log/upstart/uwsgi-emperor.log
>>>>
>>>> On Tuesday, October 22, 2013 6:48:42 PM UTC+2, curiouslearn wrote:
>>>>>
>>>>> I want to get web2py running on a Digital Ocean virtual server with 
>>>>> nginx and uWSGI. I followed the instructions on deployment recipes in 
>>>>> Web2py book, but things are not working. The following are the 
>>>>> differences 
>>>>> between the instructions given in the book and my specific case. 
>>>>>
>>>>> *Differences from instructions given in web2py deployment recipes*
>>>>> (1) I have web2py installed in "/home/username/web_apps/web2py" instead 
>>>>> of in "/home/www-data/web2py"
>>>>> (2) The configuration file is called "/etc/nginx/sites-available/
>>>>> myconfig.org" instead of "/etc/nginx/sites-available/web2py"
>>>>> (3) For now I am ignoring settings related to ssl since I am just 
>>>>> trying to get this to work.
>>>>>
>>>>> *The configuration I am using:*
>>>>>
>>>>> *1.* In the nginx file I have the following. Since I have other 
>>>>> non-web2py apps running I don't want to listen on 80:
>>>>>
>>>>> *server {*
>>>>> *
>>>>> *
>>>>> *    server_name $hostname;*
>>>>> *    listen 9001; *
>>>>> *    access_log /var/log/nginx/me.log;*
>>>>> *
>>>>> *
>>>>> *    location / {*
>>>>> *        uwsgi_pass unix:///tmp/web2py.socket;*
>>>>> *        include uwsgi_params;*
>>>>> *        uwsgi_param UWSGI_SCHEME $scheme;*
>>>>> *        uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;*
>>>>> *    }*
>>>>> *}*
>>>>>
>>>>> *
>>>>> *
>>>>> *2.* In the /etc/uwsgi/web2py.xml file I have:
>>>>>
>>>>> *<uwsgi>*
>>>>> *    <socket>/tmp/web2py.socket</socket>                   *
>>>>> *    <pythonpath>/home/username/web_apps/web2py/</pythonpath>*
>>>>> *    <mount>/=wsgihandler:application</mount>              *
>>>>> *    <master/>                          *
>>>>> *    <processes>1</processes>           *
>>>>> *    <harakiri>60</harakiri>            *
>>>>> *    <reload-mercy>8</reload-mercy>     *
>>>>> *    <cpu-affinity>1</cpu-affinity>     *
>>>>> *    <stats>/tmp/stats.socket</stats>   *
>>>>> *    <max-requests>2000</max-requests>  *
>>>>> *    <limit-as>512</limit-as>           *
>>>>> *    <reload-on-as>256</reload-on-as>   *
>>>>> *    <reload-on-rss>192</reload-on-rss> *
>>>>> *    <uid>web_apps</uid>                *
>>>>> *    <gid>web_apps</gid>                *
>>>>> *    <no-orphans/>                      *
>>>>> *</uwsgi>*
>>>>>
>>>>>
>>>>> 3. The uwsgi-emperor.conf is identical to that in the instructions.
>>>>>
>>>>> When I run sudo start uwsgi-emperor I get an error saying,
>>>>>
>>>>>      * start: Job failed to start*
>>>>>
>>>>> I have no clue what the error is. Would help setting this up. Where am 
>>>>> I making a mistake? Do I need to start web2py separately, or is the above 
>>>>> script supposed to start it?
>>>>>
>>>>> Any help in understanding where I am going wrong and getting this 
>>>>> working would be very helpful.
>>>>>
>>>>> Thank you.
>>>>>  
>>>>>
>>>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
*** Starting uWSGI 1.9.18.2 (64bit) on [Wed Oct 23 01:29:35 2013] ***
compiled with version: 4.6.3 on 22 October 2013 14:48:21
os: Linux-3.2.0-23-virtual #36-Ubuntu SMP Tue Apr 10 22:29:03 UTC 2012
nodename: webapp
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/username/temp
detected binary path: /home/username/anaconda/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 3860
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)
uWSGI http bound on :9001 fd 4
uwsgi socket 0 bound to TCP address 127.0.0.1:49679 (port auto-assigned) fd 3
Python version: 2.7.5 |Anaconda 1.6.1 (64-bit)| (default, Jun 28 2013, 
22:10:09)  [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)]
*** Python threads support is disabled. You can enable it with --enable-threads 
***
Python main interpreter initialized at 0x7864f0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145600 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
ImportError: No module named wsgihandler
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: 10010)
spawned uWSGI worker 1 (pid: 10011, cores: 1)
spawned uWSGI http 1 (pid: 10012)

--- no python application found, check your startup logs for errors ---
[pid: 10011|app: -1|req: -1/1] 77.87.13.453 () {40 vars in 713 bytes} [Wed Oct 
23 01:30:19 2013] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 1 
headers in 57 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 10011|app: -1|req: -1/2] 77.87.13.453 () {38 vars in 633 bytes} [Wed Oct 
23 01:30:20 2013] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 
500) 1 headers in 57 bytes (0 switches on core 0)
--- no python application found, check your startup logs for errors ---
[pid: 10011|app: -1|req: -1/3] 77.87.13.453 () {38 vars in 632 bytes} [Wed Oct 
23 01:30:20 2013] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 
500) 1 headers in 57 bytes (0 switches on core 0)

Attachment: wsgiconf.ini
Description: Binary data

server {

    # This block did not work until server name
    # was specified
    server_name *.mysite.org;
    location / {
        root /home/username/mysite;
        proxy_intercept_errors on;
        error_page 404 /404.html;
    }


}



##----------------------------------------------------------

upstream app1App {
    server 127.0.0.1:5001;
}

server {

    server_name app1s.mysite.org;
    access_log /var/log/nginx/me.log;

    location / {
        # host portion of the URL is available to upstream server
        proxy_set_header Host $http_host;

        # mainapp defined above in upstream block
        proxy_pass http://app1App/;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # something about changing the Location header
        proxy_redirect off;
    }

}


##---------------------------------------------------------------
upstream app2App{
    server 127.0.0.1:6001;
}

server {

    server_name app2.mysite.org;
    access_log /var/log/nginx/me.log;

    location / {
        # see above for comments of similar commands

        proxy_set_header Host $http_host;
        proxy_pass http://app2App/;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

         proxy_redirect off;
    }
}




##---------------------------------------------------------------

server {
    server_name test.mysite.org;
    access_log /var/log/nginx/me.log;

    location / {
        uwsgi_pass 127.0.0.1:9001;
        include uwsgi_params;
    }


}

Reply via email to