[web2py] Re: nginx uwsgi error 502 bad gate way
Can I just say thank you to Gour for his suggestion of setting up a virtual machine and then the same linux as on my VPS. This approach had not occurred to me, but is such a good solution to allowing me to experiment. Peter On Thursday, May 17, 2012 12:06:12 AM UTC+1, Lewis wrote: Guys, I have followed the cookbook, the posts here, and a posting at stackoverflow. I am getting error 502 bad gateway. My stuff looks like everyone else's but there are deeper layers of indirection in uwsgi itself and nginx. I have several uwsgi sym links in /etc/init.dIt is not clear which is the real one and how to invoke it. Here is the error from the nginx log. I guess I interpret this to mean that nginx can't find uwsgi: 2012/05/16 22:53:29 [error] 2460#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 76.104.195.84, server: www.lewcl.com, request: GET / HTTP/1.1, upstream: uwsgi:// 127.0.0.1:9001, host: www.lewcl.com I have no clue what to do. Guys, I think that python and web2py have a profoundly serious problem with config. Documentation is often wrong--a single punctuation mark, directory or option being off means it won't work. If we have that in our Python code it won't run, but we have great traceback and debugging tools to tell us exactly where the error is and often what the error is. But when one of 5 or 6 text files scattered across the file system is wrong, all we find out is that it won't run. There are no diagnostics (or very course ones like error). I'd like to work with some people in the community to redo a lot of the guides and get them to be accurate. I don't think script files are much of a solution (except as a way to document something that once worked on some arbitrary system). Running an arbitrary script file blindly can do serious harm to your environment. Script files are not fully debugged and recoverable setup programs. Setup is one of the hardest things to do right. It is not a throw-away task to be done at the end of the project.
[web2py] Re: nginx uwsgi error 502 bad gate way
On Sun, 20 May 2012 05:38:35 -0700 (PDT) Deidre deidre...@googlemail.com wrote: Can I just say thank you to Gour for his suggestion of setting up a virtual machine and then the same linux as on my VPS. I'm glad it was helpful to you. :-) This approach had not occurred to me, but is such a good solution to allowing me to experiment. Well, it is always easier to troubleshoot when the environment is (more) under our control. ;) Sincerely, Gour -- For him who has conquered the mind, the mind is the best of friends; but for one who has failed to do so, his mind will remain the greatest enemy. http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 signature.asc Description: PGP signature
[web2py] Re: nginx uwsgi error 502 bad gate way
On Fri, 18 May 2012 14:53:40 -0700 (PDT) Lewis lewis_le...@hotmail.com wrote: Well, I revised my init.d script to work. Config files do not work at all in any way, shape or form. Just broken utterly. It turns out even loading simple startup variables to the init script does not work. Period. [...] So, I have wasted 20 hours attempting to debug config files that are inherently unusable. Based on my experience I can say that Cherokee works with uWSGI and I believe it won't be a problem to make it work with lighttpd, although I do not have personal experience with nginx. Moreover, I also did manage to make uWSGI work with --http option. So, my well-wished suggestion is to start from the simple setup on your localhost (desktop/netbook/whatever) machine using Linux under VM (e.g. virtuablbox) if your desktop is non-Linux and make it work there. Then, knowing what's going on, you can proceed towards your Linode VPS. Sincerely, Gour -- A person is said to be established in self-realization and is called a yogī [or mystic] when he is fully satisfied by virtue of acquired knowledge and realization. Such a person is situated in transcendence and is self-controlled. He sees everything — whether it be pebbles, stones or gold — as the same. http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 signature.asc Description: PGP signature
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Thanks to Bruce Wade who suggested going all command line. In an init file with an args variable it is no problem to have a very long list of args. Roberto: I used pip to install v 1.2.3. Would it have included xml support by default? I had previously downloaded the package for xml but perhaps the default build doesn't include it. I am not in love with xml. It is what all the cookbooks and nearly every web site showed (for example, most of the django guys write up uwsgi using xml config files). I'd be perfectly happy with json or ini style config files. Is support for both built in? I had read the doc on the options but sometimes the short form is not mentioned. I'd agree that it makes sense to use long form. In answer to one of your earlier questions--yes, the options and the way uwsgi works is logical. It is very functional. The problem comes when some fundamental prereq is left out during the build or install (if retrieving some very out of date version from a repository). Then, it becomes very difficult to diagnose what is going wrong. As (very) frustrating as it was I am happy with the change. Dozens of lines of apache config are replaced by less than a dozen lines for nginx. Enough with admin for a while. Back to design and coding--the fun stuff. Case closed. On Friday, May 18, 2012 10:37:48 PM UTC-7, Roberto De Ioris wrote: Well, I revised my init.d script to work. Config files do not work at all in any way, shape or form. Just broken utterly. It turns out even loading simple startup variables to the init script does not work. Period. It would appear that for some reason the only way uwsgi works is with command line arguments, many of which aren't documented. For example, everyone uses -M. I did a search for it in the wiki. Many examples include it. The global listing of (not) all arguments does not show it. What is it? I am on a linode vps running ubuntu 11.10. The only person who logs on is me to do config horrors. I log on as root. So, the commmand line to start uwsgi is run as root. As a command line, it works. When it references any external config file it does not work. Should I file a ticket, Roberto? You'll say you can't reproduce. But, I can't reproduce it ever working at all. So, I have wasted 20 hours attempting to debug config files that are inherently unusable. Run uwsgi --help for the full list of options (and their shortcuts). I suggest you to not use shortcuts, as you will forget what they mean soon. Use long format. -M -- --master Regarding config files, read here how they works: http://projects.unbit.it/uwsgi/wiki/Doc (you do not need to read it all, just the first part). Try that (call it foo.ini) [uwsgi] http = :8080 master = true Then uwsgi --ini foo.ini Go to your browser to port 8080, it will work for sure. I suspect you are trying with xml files, but without xml support. If you really love xml format, be sure to have installed libxml2-dev as described here: http://projects.unbit.it/uwsgi/wiki/Install and rebuild uWSGI. Finally, you are on Ubuntu, throw away those ancient init scripts and use what Ubuntu wants: upstart scripts http://projects.unbit.it/uwsgi/wiki/Upstart Obviously the previous link does not show you how upstart works, but you can find more complete docs on ubuntu site (it is a lot easier than init scripts and Ubuntu will not move to SystemD, so you'd better to invest a bit of time in it). Another important link is that one: http://projects.unbit.it/uwsgi/wiki/ThingsToKnow I think you have all the pieces. -- Roberto De Ioris http://unbit.it
[web2py] Re: nginx uwsgi error 502 bad gate way
Ran that command line. Doesn't work. Instead of command line arg for processes, I put it in xml. does it matter? On Wednesday, May 16, 2012 4:06:12 PM UTC-7, Lewis wrote: Guys, I have followed the cookbook, the posts here, and a posting at stackoverflow. I am getting error 502 bad gateway. My stuff looks like everyone else's but there are deeper layers of indirection in uwsgi itself and nginx. I have several uwsgi sym links in /etc/init.dIt is not clear which is the real one and how to invoke it. Here is the error from the nginx log. I guess I interpret this to mean that nginx can't find uwsgi: 2012/05/16 22:53:29 [error] 2460#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 76.104.195.84, server: www.lewcl.com, request: GET / HTTP/1.1, upstream: uwsgi:// 127.0.0.1:9001, host: www.lewcl.com I have no clue what to do. Guys, I think that python and web2py have a profoundly serious problem with config. Documentation is often wrong--a single punctuation mark, directory or option being off means it won't work. If we have that in our Python code it won't run, but we have great traceback and debugging tools to tell us exactly where the error is and often what the error is. But when one of 5 or 6 text files scattered across the file system is wrong, all we find out is that it won't run. There are no diagnostics (or very course ones like error). I'd like to work with some people in the community to redo a lot of the guides and get them to be accurate. I don't think script files are much of a solution (except as a way to document something that once worked on some arbitrary system). Running an arbitrary script file blindly can do serious harm to your environment. Script files are not fully debugged and recoverable setup programs. Setup is one of the hardest things to do right. It is not a throw-away task to be done at the end of the project.
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Il giorno 18/mag/2012, alle ore 12:42, Lewis ha scritto: Ran that command line. Doesn't work. Instead of command line arg for processes, I put it in xml. does it matter? You mean running ps aux now shows /usr/local/bin/uwsgi -x /etc/uwsgi/uwsgi-conf.xml instead of the (wrong) /usr/local/bin/uwsgi -x /etc/uwsgi/uwsgi-conf.xml -p /var/run/uwsgi.pid ? (the second is wrong because -p takes a number, and in addition to that you have already specified the number of processes inthe xml file, so no need to double-use it) By the way try to follow that steps (run a ps aux after each step to be sue all is fine): 1) stop all (nginx, uwsgi) 2) run only nginx 3) from your terminal run (this is the minimal config for web2py) sudo /usr/local/bin/uwsgi --chdir /var/web2py/ --module wsgihandler --socket 127.0.0.1:9001 (it means: move to /var/web2py/, load wsgihandler module and bind to socket 127.0.0.1:9001) Now visit your website with your browser. Does it work ? If it does not work double check if /var/web2py is the correct path of your web2py installation. -- Roberto De Ioris http://unbit.it JID: robe...@jabber.unbit.it
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Updates: 1) On production I am not using the XML style configuration file as I was having problems with it. Instead I have set the file /etc/default/uwsgi inside this file you need two lines (you can also place other configuration) PYTHONPATH=path_to_web_2_py_project and MODULE=wsgihandler /etc/default/uwsgi --- PYTHONPATH=/home/developer/projects/yaw MODULE=wsgihandler 2) It is important to note which ever user you set uwsgi to start as ALL of your files in your project need to be owned by that user other wise the process will not start. This may be the reason you do not see the uwsgi daemon. Try this: cd path_of_web2py_project type: uwsgi uwsgi --socket 127.0.0.1:3031 -w wsgihandler.py Also very important make sure you set wsgihandler to be executable as by default is is not. chmod +x wsgihandler.py 3) Finally look at the nginx error logs I have found that the the uwsgi error logs most of the time don't help however the nginx have provided me with the access denied messages. nginx: server { listen 80; server_name youadstage youadworld.com; access_log /home/developer/projects/logs/access.log main; error_log /home/developer/projects/logs/error.log; #limit_req zone=gulag burst=200 nodelay; #charset koi8-r; rewrite ^(.*) https://new.youadworld.com$1 permanent; #access_log logs/host.access.log main; location /(\w+)/(\w+)/static/ { root /home/developer/projects/yaw/applications/; } location / { #root html; #index index.html index.htm; include uwsgi_params; uwsgi_pass 127.0.0.1:9001; } } server { listen 443; server_name youadstage youadworld.com; ssl on; ssl_certificate /home/developer/projects/yaw/settings/public.crt; ssl_certificate_key /home/developer/projects/yaw/settings/youadworld.com.key; location / { uwsgi_pass 127.0.0.1:9001; include uwsgi_params; uwsgi_param UWSGI_SCHEME $scheme; } } Hopefully this helps a bit more. -- Regards, Bruce On Fri, May 18, 2012 at 4:37 AM, Roberto De Ioris robe...@unbit.it wrote: Il giorno 18/mag/2012, alle ore 12:42, Lewis ha scritto: Ran that command line. Doesn't work. Instead of command line arg for processes, I put it in xml. does it matter? You mean running ps aux now shows /usr/local/bin/uwsgi -x /etc/uwsgi/uwsgi-conf.xml instead of the (wrong) /usr/local/bin/uwsgi -x /etc/uwsgi/uwsgi-conf.xml -p /var/run/uwsgi.pid ? (the second is wrong because -p takes a number, and in addition to that you have already specified the number of processes inthe xml file, so no need to double-use it) By the way try to follow that steps (run a ps aux after each step to be sue all is fine): 1) stop all (nginx, uwsgi) 2) run only nginx 3) from your terminal run (this is the minimal config for web2py) sudo /usr/local/bin/uwsgi --chdir /var/web2py/ --module wsgihandler --socket 127.0.0.1:9001 (it means: move to /var/web2py/, load wsgihandler module and bind to socket 127.0.0.1:9001) Now visit your website with your browser. Does it work ? If it does not work double check if /var/web2py is the correct path of your web2py installation. -- Roberto De Ioris http://unbit.it JID: robe...@jabber.unbit.it -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Bruce: do you only need two lines of uwsgi config? Where do you put the rest of the directives? command line? Does anyone know how to have one uwsgi config file load another (as we do in apache)? I was trying to see an example or find it in uwsgi docs to no avail. On Friday, May 18, 2012 6:52:10 AM UTC-7, Bruce Wade wrote: Updates: 1) On production I am not using the XML style configuration file as I was having problems with it. Instead I have set the file /etc/default/uwsgi inside this file you need two lines (you can also place other configuration) PYTHONPATH=path_to_web_2_py_project and MODULE=wsgihandler /etc/default/uwsgi --- PYTHONPATH=/home/developer/projects/yaw MODULE=wsgihandler 2) It is important to note which ever user you set uwsgi to start as ALL of your files in your project need to be owned by that user other wise the process will not start. This may be the reason you do not see the uwsgi daemon. Try this: cd path_of_web2py_project type: uwsgi uwsgi --socket 127.0.0.1:3031 -w wsgihandler.py Also very important make sure you set wsgihandler to be executable as by default is is not. chmod +x wsgihandler.py 3) Finally look at the nginx error logs I have found that the the uwsgi error logs most of the time don't help however the nginx have provided me with the access denied messages. nginx: server { listen 80; server_name youadstage youadworld.com; access_log /home/developer/projects/logs/access.log main; error_log /home/developer/projects/logs/error.log; #limit_req zone=gulag burst=200 nodelay; #charset koi8-r; rewrite ^(.*) https://new.youadworld.com$1 permanent; #access_log logs/host.access.log main; location /(\w+)/(\w+)/static/ { root /home/developer/projects/yaw/applications/; } location / { #root html; #index index.html index.htm; include uwsgi_params; uwsgi_pass 127.0.0.1:9001; } } server { listen 443; server_name youadstage youadworld.com; ssl on; ssl_certificate /home/developer/projects/yaw/settings/public.crt; ssl_certificate_key /home/developer/projects/yaw/settings/youadworld.com.key; location / { uwsgi_pass 127.0.0.1:9001; include uwsgi_params; uwsgi_param UWSGI_SCHEME $scheme; } } Hopefully this helps a bit more. -- Regards, Bruce On Fri, May 18, 2012 at 4:37 AM, Roberto De Ioris robe...@unbit.itwrote: Il giorno 18/mag/2012, alle ore 12:42, Lewis ha scritto: Ran that command line. Doesn't work. Instead of command line arg for processes, I put it in xml. does it matter? You mean running ps aux now shows /usr/local/bin/uwsgi -x /etc/uwsgi/uwsgi-conf.xml instead of the (wrong) /usr/local/bin/uwsgi -x /etc/uwsgi/uwsgi-conf.xml -p /var/run/uwsgi.pid ? (the second is wrong because -p takes a number, and in addition to that you have already specified the number of processes inthe xml file, so no need to double-use it) By the way try to follow that steps (run a ps aux after each step to be sue all is fine): 1) stop all (nginx, uwsgi) 2) run only nginx 3) from your terminal run (this is the minimal config for web2py) sudo /usr/local/bin/uwsgi --chdir /var/web2py/ --module wsgihandler --socket 127.0.0.1:9001 (it means: move to /var/web2py/, load wsgihandler module and bind to socket 127.0.0.1:9001) Now visit your website with your browser. Does it work ? If it does not work double check if /var/web2py is the correct path of your web2py installation. -- Roberto De Ioris http://unbit.it JID: robe...@jabber.unbit.it -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Bruce: do you only need two lines of uwsgi config? Where do you put the rest of the directives? command line? Does anyone know how to have one uwsgi config file load another (as we do in apache)? I was trying to see an example or find it in uwsgi docs to no avail. http://projects.unbit.it/uwsgi/wiki/ParsingOrder -- Roberto De Ioris http://unbit.it
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
That is the only two lines I have nothing set on the command line. uwsgi should by default look into that directory. Oh yes there is one other thing you need to change in /etc/init.d/uwsgi (if you have this) the path to uwsgi is /usr/local/bin/uwsgi You also set in that file OWNER NAME DESC /etc/init.d/uwsgi: PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/uwsgi OWNER=uwsgi NAME=uwsgi DESC=uwsgi echo Trying test test -x $DAEMON || exit 0 echo test passed # Include uwsgi defaults if available if [ -f /etc/default/uwsgi ] ; then . /etc/default/uwsgi fi set -e # I added --limit-post 4096 to prevent post attacks DAEMON_OPTS=-s 127.0.0.1:9001 -M 4 -t 30 -A 4 -p 4 -d /var/log/uwsgi.log --pythonpath $PYTHONPATH --module $MODULE --limit-post 4096 case $1 in start) echo -n Starting $DESC: start-stop-daemon --start --chuid $OWNER:$OWNER --user $OWNER \ --exec $DAEMON -- $DAEMON_OPTS echo $NAME. ;; stop) echo -n Stopping $DESC: start-stop-daemon --signal 3 --user $OWNER --quiet --retry 2 --stop \ --exec $DAEMON echo $NAME. ;; reload) killall -1 $DAEMON ;; force-reload) killall -15 $DAEMON ;; restart) echo -n Restarting $DESC: start-stop-daemon --signal 3 --user $OWNER --quiet --retry 2 --stop \ --exec $DAEMON sleep 1 start-stop-daemon --user $OWNER --start --quiet --chuid $OWNER:$OWNER \ --exec $DAEMON -- $DAEMON_OPTS echo $NAME. ;; status) killall -10 $DAEMON ;; *) N=/etc/init.d/$NAME echo Usage: $N {start|stop|restart|reload|force-reload|status} 2 exit 1 ;; esac exit 0 On Fri, May 18, 2012 at 10:58 AM, Roberto De Ioris robe...@unbit.it wrote: Bruce: do you only need two lines of uwsgi config? Where do you put the rest of the directives? command line? Does anyone know how to have one uwsgi config file load another (as we do in apache)? I was trying to see an example or find it in uwsgi docs to no avail. http://projects.unbit.it/uwsgi/wiki/ParsingOrder -- Roberto De Ioris http://unbit.it -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Success! --but it's not clear why!?! I ran uwsgi with the following commmand line (note that I switched to unix sock in my location directive in nginx to match...): uwsgi -s /tmp/web2py.sock --module wsgihandler --pythonpath /var/web2py --daemonize /var/log/uwsgi.log This means that there is something funky in either my init script or in my xml: Bruce: thanks for the init suggestions. Mine was similar but I did not set OWNER (I would use www-data as I don't have a uwsgi user) and I did not set .e. Roberto: I'll look at the parsing order link you sent. Well, now I know it does work and can work with a known good setting. After I try to debug the manly, professional approach I can always revert to the cmd line or to using ini file approach. Trial and error is not fun. I have something that works but I still don't know what was broke. Thanks everyone. I'll do a write up that is more theory and practice rather than cookbook. There are too many variations to rely on anyone else's cookbook unless your own config is nearly identical to one that you try to mimic. On Friday, May 18, 2012 11:03:52 AM UTC-7, Bruce Wade wrote: That is the only two lines I have nothing set on the command line. uwsgi should by default look into that directory. Oh yes there is one other thing you need to change in /etc/init.d/uwsgi (if you have this) the path to uwsgi is /usr/local/bin/uwsgi You also set in that file OWNER NAME DESC /etc/init.d/uwsgi: PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/uwsgi OWNER=uwsgi NAME=uwsgi DESC=uwsgi echo Trying test test -x $DAEMON || exit 0 echo test passed # Include uwsgi defaults if available if [ -f /etc/default/uwsgi ] ; then . /etc/default/uwsgi fi set -e # I added --limit-post 4096 to prevent post attacks DAEMON_OPTS=-s 127.0.0.1:9001 -M 4 -t 30 -A 4 -p 4 -d /var/log/uwsgi.log --pythonpath $PYTHONPATH --module $MODULE --limit-post 4096 case $1 in start) echo -n Starting $DESC: start-stop-daemon --start --chuid $OWNER:$OWNER --user $OWNER \ --exec $DAEMON -- $DAEMON_OPTS echo $NAME. ;; stop) echo -n Stopping $DESC: start-stop-daemon --signal 3 --user $OWNER --quiet --retry 2 --stop \ --exec $DAEMON echo $NAME. ;; reload) killall -1 $DAEMON ;; force-reload) killall -15 $DAEMON ;; restart) echo -n Restarting $DESC: start-stop-daemon --signal 3 --user $OWNER --quiet --retry 2 --stop \ --exec $DAEMON sleep 1 start-stop-daemon --user $OWNER --start --quiet --chuid $OWNER:$OWNER \ --exec $DAEMON -- $DAEMON_OPTS echo $NAME. ;; status) killall -10 $DAEMON ;; *) N=/etc/init.d/$NAME echo Usage: $N {start|stop|restart|reload|force-reload|status} 2 exit 1 ;; esac exit 0 On Fri, May 18, 2012 at 10:58 AM, Roberto De Ioris robe...@unbit.itwrote: Bruce: do you only need two lines of uwsgi config? Where do you put the rest of the directives? command line? Does anyone know how to have one uwsgi config file load another (as we do in apache)? I was trying to see an example or find it in uwsgi docs to no avail. http://projects.unbit.it/uwsgi/wiki/ParsingOrder -- Roberto De Ioris http://unbit.it -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com On Friday, May 18, 2012 11:03:52 AM UTC-7, Bruce Wade wrote: That is the only two lines I have nothing set on the command line. uwsgi should by default look into that directory. Oh yes there is one other thing you need to change in /etc/init.d/uwsgi (if you have this) the path to uwsgi is /usr/local/bin/uwsgi You also set in that file OWNER NAME DESC /etc/init.d/uwsgi: PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/uwsgi OWNER=uwsgi NAME=uwsgi DESC=uwsgi echo Trying test test -x $DAEMON || exit 0 echo test passed # Include uwsgi defaults if available if [ -f /etc/default/uwsgi ] ; then . /etc/default/uwsgi fi set -e # I added --limit-post 4096 to prevent post attacks DAEMON_OPTS=-s 127.0.0.1:9001 -M 4 -t 30 -A 4 -p 4 -d /var/log/uwsgi.log --pythonpath $PYTHONPATH --module $MODULE --limit-post 4096 case $1 in start) echo -n Starting $DESC: start-stop-daemon --start --chuid $OWNER:$OWNER --user $OWNER \ --exec $DAEMON -- $DAEMON_OPTS echo $NAME. ;; stop) echo -n Stopping $DESC: start-stop-daemon --signal 3 --user $OWNER --quiet --retry 2 --stop \ --exec $DAEMON echo $NAME. ;; reload)
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Well, I revised my init.d script to work. Config files do not work at all in any way, shape or form. Just broken utterly. It turns out even loading simple startup variables to the init script does not work. Period. It would appear that for some reason the only way uwsgi works is with command line arguments, many of which aren't documented. For example, everyone uses -M. I did a search for it in the wiki. Many examples include it. The global listing of (not) all arguments does not show it. What is it? I am on a linode vps running ubuntu 11.10. The only person who logs on is me to do config horrors. I log on as root. So, the commmand line to start uwsgi is run as root. As a command line, it works. When it references any external config file it does not work. Should I file a ticket, Roberto? You'll say you can't reproduce. But, I can't reproduce it ever working at all. So, I have wasted 20 hours attempting to debug config files that are inherently unusable. On Friday, May 18, 2012 12:18:39 PM UTC-7, Lewis wrote: Success! --but it's not clear why!?! I ran uwsgi with the following commmand line (note that I switched to unix sock in my location directive in nginx to match...): uwsgi -s /tmp/web2py.sock --module wsgihandler --pythonpath /var/web2py --daemonize /var/log/uwsgi.log This means that there is something funky in either my init script or in my xml: Bruce: thanks for the init suggestions. Mine was similar but I did not set OWNER (I would use www-data as I don't have a uwsgi user) and I did not set .e. Roberto: I'll look at the parsing order link you sent. Well, now I know it does work and can work with a known good setting. After I try to debug the manly, professional approach I can always revert to the cmd line or to using ini file approach. Trial and error is not fun. I have something that works but I still don't know what was broke. Thanks everyone. I'll do a write up that is more theory and practice rather than cookbook. There are too many variations to rely on anyone else's cookbook unless your own config is nearly identical to one that you try to mimic. On Friday, May 18, 2012 11:03:52 AM UTC-7, Bruce Wade wrote: That is the only two lines I have nothing set on the command line. uwsgi should by default look into that directory. Oh yes there is one other thing you need to change in /etc/init.d/uwsgi (if you have this) the path to uwsgi is /usr/local/bin/uwsgi You also set in that file OWNER NAME DESC /etc/init.d/uwsgi: PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/uwsgi OWNER=uwsgi NAME=uwsgi DESC=uwsgi echo Trying test test -x $DAEMON || exit 0 echo test passed # Include uwsgi defaults if available if [ -f /etc/default/uwsgi ] ; then . /etc/default/uwsgi fi set -e # I added --limit-post 4096 to prevent post attacks DAEMON_OPTS=-s 127.0.0.1:9001 -M 4 -t 30 -A 4 -p 4 -d /var/log/uwsgi.log --pythonpath $PYTHONPATH --module $MODULE --limit-post 4096 case $1 in start) echo -n Starting $DESC: start-stop-daemon --start --chuid $OWNER:$OWNER --user $OWNER \ --exec $DAEMON -- $DAEMON_OPTS echo $NAME. ;; stop) echo -n Stopping $DESC: start-stop-daemon --signal 3 --user $OWNER --quiet --retry 2 --stop \ --exec $DAEMON echo $NAME. ;; reload) killall -1 $DAEMON ;; force-reload) killall -15 $DAEMON ;; restart) echo -n Restarting $DESC: start-stop-daemon --signal 3 --user $OWNER --quiet --retry 2 --stop \ --exec $DAEMON sleep 1 start-stop-daemon --user $OWNER --start --quiet --chuid $OWNER:$OWNER \ --exec $DAEMON -- $DAEMON_OPTS echo $NAME. ;; status) killall -10 $DAEMON ;; *) N=/etc/init.d/$NAME echo Usage: $N {start|stop|restart|reload|force-reload|status} 2 exit 1 ;; esac exit 0 On Fri, May 18, 2012 at 10:58 AM, Roberto De Ioris robe...@unbit.itwrote: Bruce: do you only need two lines of uwsgi config? Where do you put the rest of the directives? command line? Does anyone know how to have one uwsgi config file load another (as we do in apache)? I was trying to see an example or find it in uwsgi docs to no avail. http://projects.unbit.it/uwsgi/wiki/ParsingOrder -- Roberto De Ioris http://unbit.it -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.fittraineronline.com - Fitness Personal Trainers Online http://www.warplydesigned.com On Friday, May 18, 2012 11:03:52 AM UTC-7, Bruce Wade wrote: That is the only two lines I have nothing set on the command line. uwsgi should by default look into that directory. Oh yes there
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Well, I revised my init.d script to work. Config files do not work at all in any way, shape or form. Just broken utterly. It turns out even loading simple startup variables to the init script does not work. Period. It would appear that for some reason the only way uwsgi works is with command line arguments, many of which aren't documented. For example, everyone uses -M. I did a search for it in the wiki. Many examples include it. The global listing of (not) all arguments does not show it. What is it? I am on a linode vps running ubuntu 11.10. The only person who logs on is me to do config horrors. I log on as root. So, the commmand line to start uwsgi is run as root. As a command line, it works. When it references any external config file it does not work. Should I file a ticket, Roberto? You'll say you can't reproduce. But, I can't reproduce it ever working at all. So, I have wasted 20 hours attempting to debug config files that are inherently unusable. Run uwsgi --help for the full list of options (and their shortcuts). I suggest you to not use shortcuts, as you will forget what they mean soon. Use long format. -M -- --master Regarding config files, read here how they works: http://projects.unbit.it/uwsgi/wiki/Doc (you do not need to read it all, just the first part). Try that (call it foo.ini) [uwsgi] http = :8080 master = true Then uwsgi --ini foo.ini Go to your browser to port 8080, it will work for sure. I suspect you are trying with xml files, but without xml support. If you really love xml format, be sure to have installed libxml2-dev as described here: http://projects.unbit.it/uwsgi/wiki/Install and rebuild uWSGI. Finally, you are on Ubuntu, throw away those ancient init scripts and use what Ubuntu wants: upstart scripts http://projects.unbit.it/uwsgi/wiki/Upstart Obviously the previous link does not show you how upstart works, but you can find more complete docs on ubuntu site (it is a lot easier than init scripts and Ubuntu will not move to SystemD, so you'd better to invest a bit of time in it). Another important link is that one: http://projects.unbit.it/uwsgi/wiki/ThingsToKnow I think you have all the pieces. -- Roberto De Ioris http://unbit.it
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
Is it conceivable that a uwsgi + nginx bundle could be produced making python deployment super easy?
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
You mean like a virtual machine? or an installation script? On Thursday, 17 May 2012 10:34:57 UTC-5, pbreit wrote: Is it conceivable that a uwsgi + nginx bundle could be produced making python deployment super easy?
[web2py] Re: nginx uwsgi error 502 bad gate way
I'd agree that Python deployment remains unnecessarily difficult. I also agree that just running random scripts isn't the best approach. However I think it can be very helpful to run the commands manually that you find in a script. Then you really know what is being performed and can create your own scripts. In terms of figuring out your problem, might be useful to see relevant parts of nginx.conf.
[web2py] Re: nginx uwsgi error 502 bad gate way
On Thu, 17 May 2012 06:22:20 +0200 Roberto De Ioris robe...@unbit.it wrote: If you are able to follow it, then adding a webserver should be a pretty easy task (and yesterday, uWSGI got https support so you do not even need a full webserver for simple deployments) What is considered 'simple deployment'? At the moment we use lighttpd for a few small-medium PHP-based sites which we plan to migrate (with a time) to web2py-based CMS. Does this scenario count in? Sincerely, Gour -- As the ignorant perform their duties with attachment to results, the learned may similarly act, but without attachment, for the sake of leading people on the right path. http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 signature.asc Description: PGP signature
Re: [web2py] Re: nginx uwsgi error 502 bad gate way
On Thu, 17 May 2012 06:22:20 +0200 Roberto De Ioris robe...@unbit.it wrote: If you are able to follow it, then adding a webserver should be a pretty easy task (and yesterday, uWSGI got https support so you do not even need a full webserver for simple deployments) What is considered 'simple deployment'? In my mind, less than 20 concurrent connections :) For others it is often a matter of money, if i get 10$ for configuring a webserver would you prefer to setup lighttpd/nginx/apache/cherokee/mongrel2 + uwsgi/gunicorn/mod_wsgi or simply do: uwsgi --https :443,cert.pem,cert.key --wsgi-file web2py/wsgihandler.py --master --processes 4 obviously if you start needing features, like client certificate management, ssl caching and so on, the uWSGI https implementation is no more than a toy. -- Roberto De Ioris http://unbit.it
[web2py] Re: nginx uwsgi error 502 bad gate way
On Thu, 17 May 2012 07:27:53 +0200 Roberto De Ioris robe...@unbit.it wrote: In my mind, less than 20 concurrent connections :) Good. I'm in. ;) For others it is often a matter of money, if i get 10$ for configuring a webserver would you prefer to setup lighttpd/nginx/apache/cherokee/mongrel2 + uwsgi/gunicorn/mod_wsgi or simply do: uwsgi --https :443,cert.pem,cert.key --wsgi-file web2py/wsgihandler.py --master --processes 4 Fair enough. obviously if you start needing features, like client certificate management, ssl caching and so on, the uWSGI https implementation is no more than a toy. Probably good-enough for our anticipated setup. Sincerely, Gour -- Never was there a time when I did not exist, nor you, nor all these kings; nor in the future shall any of us cease to be. http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810 signature.asc Description: PGP signature