w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Django ignoring environment variables when run via uWSGI
It cannot work as bash config files are read by the bash. You have to set var in the emperor or in the vassal (the second one is a better approach). Just add env=DJANGO_MODE=foobar to your config (do not use whitespace).

Categories : Django

uwsgi socket not created
The problem was invalid syntax in my xml uwsgi file. The socket wasn't being created because the server wasn't being started because it couldn't read the uwsgi config file, because I had mismatched xml tags: wsgi-file and wsgi_file. That line was unnecessary anyway, so I deleted it and the socket was created again.

Categories : Sockets

uWSGI & gevent persistent network socket connection
Once you enable the gevent mode uWSGI became purely (and purely means no monkey-pathing needed) event-driven (otherwise there would be no advantage in using gevent). Gevent means event driven + greenlet (avoiding you to write callback-hell based code like in node.js) More on the magic here: http://uwsgi-docs.readthedocs.org/en/latest/Async.html WSGI applications are, well, applications, so if you want to have persistent connections, just open it on server startup or something similar, you do not need special support like in php.

Categories : Python

Django, nginx and uWSGI caching results until uWSGI/MySQL restart
I had the same behavior and found this post https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k Adding this line on settings.py (only the OPTIONS key) on Django: DATABASES = { 'default': { 'OPTIONS': { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED", } } } seems to have resolved the problem.

Categories : Mysql

uwsgi: find: `/etc/uwsgi/s-enabled': No such file or directory
Check your uwsgi config file, it should probably be /etc/uwsgi/apps-enabled this directory holds the uwsgi app's ini files either via symlinks from directory /etc/uwsgi/apps-available/ or you can have ini files directly here. example with symlink: ln -s /etc/uwsgi/apps-available/testApp.ini /etc/uwsgi/apps-enabled/testApp.ini Installation of uwsgi and it's configuration on ubuntu can be found here django + uwssgi + nginx on ubuntu Installation of same on centOS6 can be found here uwsgi + gevent + flask + nginx + mongodb on centOS6

Categories : Misc

What does "You should probably `chown` them" mean?
chown is used to change who has the ownership of a file. In this case the reference to sudo implies that files installed as the superuser will not be accesible by homebrew when run by a regular user rendering these options useless, and most likely causing an error or undesired result if such a file is attempted to be accessed

Categories : Osx

Why ordinary user cannot use chgrp/chown
If any user could successfully call the chown(2) syscall (e.g. thru chrgrp and chown commands) on files not belonging to him, the user-based access protection provided by the Linux kernel would be useless. A malicious user would change ownership of every file whose access is limited to him Of course, the user could execute the chown command (e.g. by typing /usr/bin/chown file) but if called from an ordinary user these commands will fail (and have a non-zero exit code) because the underlying chown(2) syscall would fail. NB: as documented, an ordinary user may chgrp to some group he belongs to.

Categories : Linux

brew install - permission denied (after chown -R `whoami` )
trojanfoe's answer helped. There was a permission issue with the Library/Logs folder that I wasn't assigned to, but somehow the Library/Caches/Homebrew folder didn't exist. So I just created that, the subfolder Formula, and changed the permission and everything installed just fine. It actually cleared up a lot of errors I was having. Thanks everyone. Update @fet's one liner works great. mkdir -p ~/Library/Caches/Homebrew/Formula

Categories : Osx

How to aggregate in R ignoring some rows for some fields, and not ignoring them for others?
Use aggregate, with both the arguments na.action=na.pass and na.rm=TRUE. The former tells aggregate not to remove rows where NAs are present; and the latter is the action that the aggregating function should take. aggregate(cbind(qA, qB, qC) ~ city, df, mean, na.action=na.pass, na.rm=TRUE)

Categories : R

Python bottle vs uwsgi/bottle vs nginx/uwsgi/bottle
Flask vs Bottle comes down to a couple of things for me. How simple is the app. If it is very simple, then bottle is my choice. If not, then I got with Flask. The fact that bottle is a single file makes it incredibly simple to deploy with by just including the file in our source. But the fact that bottle is a single file should be a pretty good indication that it does not implement the full wsgi spec and all of its edge cases. What does the app do. If it is going to have to render anything other than Python->JSON then I go with Flask for its built in support of Jinja2. If I need to do authentication and/or authorization then Flask has some pretty good extensions already for handling those requirements. If I need to do caching, again, Flask-Cache exists and does a pretty good job w

Categories : Python

Will select (or epoll) mark a socket as readable if there is data on the socket prior to adding the socket to the list of monitored file descriptor
will select now immediately let me know that the socket is readable? Yes. What, if in step 5, the peer does not send me any data but say, since a FIN. Will select still tell me that the socket is readable Yes. in summary, the question is if select(or any of its variants such as epoll) indicate that a socket is readable if there has been any activity on the socket prior to including the socket in the list of monitored file descriptors and assuming that the application has read no data from the socket Yes.

Categories : Sockets

How do I run uwsgi with virtualenv
Use -H to set virtualenv to python path. uwsgi -H /path/to/your/virtualenv http://uwsgi-docs.readthedocs.org/en/latest/Options.html#virtualenv

Categories : Python

managing uWSGI with Upstart
You probably have daemonize=some/log/file/path in your ini file. That will make the process exit with a "normal" exit code, so Upstart will figure that you wanted the job stopped and terminate the job. Remove daemonize and upstart will track the process in the foreground.

Categories : Python

how to kill uWSGI process
The recommended way to signal reloading of application data is to use the --touch-reload option. Sample syntax on a .ini fine is: touch-reload /var/run/uwsgi/app/myapp/reload Where myappis your application name. /var/run/uwsgi/app is the recommended place for such files (could be anywhere). The reload file is an empty file whose timestamp is watched by uwsgi, whenever it changes (by, for example, using touch) uWSGI detects that change and restarts the corresponding uWSGI application instance. So, whenever you update your code you should touch the file in order to update the in-memory version of the application. For example, on bash: sudo touch /var/run/uwsgi/app/myapp/reload Note --reload is an undocumented option on current uWSGI version.

Categories : Misc

nginx loadbalancing in uwsgi
The first approach is a lot saner and avoids nginx to pass requests to a worker already busy. You may find some blog posts or doc about the thundering herd problem, i suggest you to read this: http://uwsgi-docs.readthedocs.org/en/latest/articles/SerializingAccept.html basically unless you are on very specific needs (and limits) the first approach is the way to go.

Categories : Nginx

How to read uwsgi stats output
WID -> worker id % -> percentage of served requests by the worker PID -> process id of the worker REQ -> number of managed requests RPS -> number of current requests handled per second EXC -> number of raised exceptions SIG -> number of managed uwsgi signals (NOT unix signals !!!) STATUS -> can be idle, busy, pause, cheaped or sig AVG -> average response time for the worker RSS -> RSS memory (need --memory-report) VSZ -> address space (need --memory-report) TX -> transmitted data RunT -> running time

Categories : Misc

How to figure out 500 error in uwsgi environment
Your uWSGI logs should reveal more about the issue. For starters, the logs should reveal what the request URI was for the requests that errored: [pid: 29526|app: 0|req: 1/1] 127.0.0.1 () {28 vars in 297 bytes} [Mon Apr 21 00:11:46 2014] GET /example => generated 4 bytes in 0 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0) In this case, it was a request to /example. This may reveal a pattern as to what is causing the error. Separately, if the error is caused by Python somewhere, then uncaught tracebacks will be recorded (via stderr) in the same fashion. To simplify debugging the issue, you may want to consider running uWSGI using just its in-built HTTP router (via uwsgi --http :8080 ...) and making direct requests to that.

Categories : Django

uWSGI for uploading and processing files
If the file upload takes minutes, how will uWSGI be capable of handling other clients without blocking? It will block. A solution is to put a webserver like NGINX in front of uWSGI that pre-buffers the POST request. So the file upload will be actually bound to an NGINX handler until is completed and then passed to the uWSGI handler. Is there any way the processing can be offloaded using built in functionality in uWSGI so that the user get a response after upload and can query for processing status? You need to create a task queue system to offload the processing from the web handler. This is a common best practice. Just look around for python task queues. For builtin functionalities it really depends on the task you need to offload. You can use the builtin uWSGI spooler, o

Categories : Python

Difference between workers and processes in uwsgi
workers and processes are indeed synonyms and the same thing. (I'm sure you've seen the configuration option documentation for them both) That configuration is very incorrect and could actually have no effect as a result. (I just found out that by having the cheaper option twice in one of my ini files neither was being picked up - but I don't know if this is the case with workers/processes).

Categories : Misc

How to set maximum request time in uWSGI?
Look at uwsgi timeouts: harakiri, socket-timeout, http-timeout.

Categories : Nginx

Stop uwsgi performing harakiri (seriously)
harakiri is something you voluntary enable with --harakiri, by default there is no such feature. Check your configuration for it. Another possibility could be you are running without the master process (you should have a warning about it) and set an alarm() without defining a signal handler for SIGALRM

Categories : Python

Running a subprocess in uwsgi application
I have found a good alternative: https://github.com/ui/django-rq , which is easy to install and configure, and it does the job correctly. Original problem with subprocesses is still unclear though.

Categories : Django

access static files as well from uWSGI
uwsgi needs a Python app to serve the URL. As http://uwsgi-docs.readthedocs.org/en/latest/HTTP.html#can-i-use-uwsgi-s-http-capabilities-in-production said: If you want to use it as a real webserver you should take into account that serving static files in uWSGI instances is possible, but not as good as using a dedicated full-featured web server. In a normal case, the clients send HTTP requests to Nginx or some other web server, which handles static files' responses and leaves the rest to uwsgi. You might be better ask that on http://serverfault.com/about

Categories : Python

ladon + uwsgi: unable to load app
I strongly suggest you to invest some time in understanding PYTHONPATH/sys.path, is one of the most important aspect of the python world but lot of users underestimate it (and you can note how it is one of the most prominent cause for errors during deployment). Your problem is that the python VM has no way to know where serverL module is, so you should add '/path/script/src' to the pythonpath (you have various way to do it, the fastest is using the --pythonpath uWSGI option)

Categories : Python

uWSGI suitable for Rails production app?
I met the same issue recently. I did some investigation and successfully deployed a Rails web site onto uwsgi. http://projects.unbit.it/uwsgi/wiki states that the support for Ruby is "Stable". So I think it is ready for production.

Categories : Ruby On Rails

Setting up django with uwsgi and nginx
ImportError: Import by filename is not supported. The --module directive expect a module, not a file. You should use --wsgi-file instead.

Categories : Python

Django app with Nginx + uWSGI on Amazon EC2
Simple Example used FastCGI Deamon in Amazon EC2 django.sh -> https://gist.github.com/romuloigor/5707566 nginx.conf -> https://gist.github.com/romuloigor/5707527

Categories : Django

uWSGI error perl application not found
Running Step#3 generates the files required for a Dancer project on the fly. I wonder if it might be this step that's causing the problem you're seeing. It might be related to how cpanm Dancer is installed locally. I've run all the steps and uploaded the working project here: https://github.com/johncosta/example-dancer-on-dotcloud git clone https://github.com/johncosta/example-dancer-on-dotcloud dotcloud create dancer dotcloud push dancer Does this yield better results?

Categories : Perl

Pyramid uWSGI deploy and not iterable 'Router'
I think that you do not need the module option, but rather just a wsgi.py file that exposes your wsgi app as the application variable. To do this, a typical wsgi.py file might look like: import os.path from pyramid.paster import get_app from pyramid.paster import setup_logging here = os.path.dirname(os.path.abspath(__file__)) inipath = os.path.join(here, 'production.ini') setup_logging(inipath) application = get_app(inipath) This would configure your app to load the production.ini file that is in the same folder as the wsgi.py file.

Categories : Python

Internal Server Error with Django and uWSGI
Check out my blog post on deploying Django behind uwsgi http://blog.johannesklug.de/2012/11/27/deploying-django-behind-nginx-with-uwsgi-and-virtualenv/. I created an ini-File to setup uwsgi, which points to the app callable with the parameter module=project.wsgi:application. The whole file reads something like this: (env)[project@host ~]$ cat uwsgi.ini [uwsgi] # path to where you put your project code chdir=/home/project/project # python path to the wsgi module, check if you have one module=project.wsgi:application # this switch tells uwsgi to spawn a master process, # that will dynamically spawn new child processes for # server requests master=True # uwsgi stores the pid of your master process here pidfile=/home/project/master.pid vacuum=True # path to your virtual environment home=/

Categories : Django

nginx, django -- uwsgi does not see POST data
x=request.body This should be the first line in any django app ran by wsgi. Then POST DATA works. Django just must read the body of request immediately if it is used later. However, there still is this problem: invalid uwsgi request (current strsize: 16705). skip. So I it is difficult to use uwsgi in this setting. I solved this by the use of fcgi, which does not have such limits. Justification: strsize is not configurable -- http://comments.gmane.org/gmane.comp.python.wsgi.uwsgi.general/5712 Edit: Roberto is right -- strsize is unrelated to request's body and it WORKS even in uwsgi. Debugging a problem during travelling, nights etc is not always a good idea ;) However, Django must read the body request immediately and this is beyond doubt. The request's body must be read prior doing a

Categories : Python

uWSGI processes lose Django sessions
Have you checked your SESSION_ENGINE ? for example if you set it to use the django caching and set it to locmem:// you will have this kind of problems Another (possible even if hard to happen) problem (if you are in --lazy/--lazy-apps mode) could be a process with an old copy of the code, have you tried reloading the whole instance ?

Categories : Python

uWSGI for running Python 2 and Python3 with django
Your uWSGI binary is linked with a specific libpython (the 3.3 one). You have to build a second copy of uWSGI for python2.7 or use a modular build: (from source directory) python3 uwsgiconfig.py --build nolang python3 uwsgiconfig.py --plugin plugins/python nolang python33 python2 uwsgiconfig.py --plugin plugins/python nolang python27 you will end with a 'uwsgi' binary and 'python33_plugin.so' and 'python27_plugin.so'

Categories : Python

Difference between nginx module and uWSGI plugin
To be nginx-friendly a module must be non-blocking and must not use calls like fork(). If you can write a nginx module like this, use the nginx approach. The problem is that all of the current available nginx modules for mongodb are blocking (they generally use threadpools but can potentially blocks). The only solution would be reimplementing the mongodb protocol (check this project http://mojolicio.us/perldoc/Mango) without using the currently available libraries. On the other side uWSGI has not such limits (it can use processes, threads and coroutines), and a gridfs module is already available: http://uwsgi-docs.readthedocs.org/en/latest/GridFS.html The problem is that there is no doc about writing uwsgi plugins, so you have to base yourself on the current available ones Btw, you ne

Categories : Nginx

Python: uWSGI configuration for NGINX+FLASK
This question is popular now, so I've improved this answer a bit. I've moved the most important points from the comments. Yep, that's the normal behavior. Nginx's master process needs root privileges to manage listening sockets on the machine. This forum thread states that you can change it, but it may cause problems. However, Nginx does allow to change the owner of the worker processes. It depends on how the uWSGI was installed. If uWSGI was installed via apt-get you can start (stop, restart) like this: service uwsgi <action> You installed uWSGI via pip, so the daemonize option will do the trick: /path/to/uwsgi --daemonize /path/to/logfile You can start it under any user you want, BUT if you decide to run it under root, you should specify the gid and uid options. uWSGI's bes

Categories : Python

Nginx+bottle+uwsgi Server returning 404 on every request
Are you sure that NGINX and UWSGI are working properly? Lot's of things could be wrong, I recommend you to follow this guide: https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html It's a step by step to setup NGINX and UWSGI with Django but I'm pretty sure you can apply it to any other web app than Django.

Categories : Python

502 Bad Gateway error Nginx and uWSGI in deploying Flask app
With uwsgi_pass 127.0.0.1:9001; you declared to Nginx your intent to talk to uWSGI through TCP socket, but have not warned uWSGI about it. Try adding a corresponding socket line to your /etc/default/uwsgi file: PYTHONPATH=/var/www/reframeit-im MODULE=wsgi socket=127.0.0.1:9001

Categories : Nginx

How can I give input with getpass to a Flask app when deploying with uWSGI?
Just add --honour-stdin it will disable the remapping of file descriptor 0 to /dev/null if you call --daemonize you will lose controlling terminal, so you have to postpone daemonization after the input has been read using --daemonize2

Categories : Python

How to track down a Python/Django/uwsgi/nginx timeout
You have a pretty "strange" setup: nginx -> uwsgi http router -> uwsgi instead of nginx -> uwsgi maybe you have some good reason for it, but in such a case you need to set the timeout between uwsgi http router and uwsgi via --http-timeout 1800 If the http router is not you want/need you can just let uwsgi speaks http with the --http-socket option

Categories : Python

Are uwsgi processes stuck when using Comet(Long Polling)?
Your analysis is right, long-polling is not well-suited for multiprocesses or multithreads modes (in term of costs). Each process/thread can manage a single request. Lucky enough uWSGI supports dozens of non-blocking/evented/microthreads-based technologies (like gevent, or lower-levels greenlets), if your app can be adapted to this patterns (and this is not a no-brain task, so do not hope monkey-patching will be enough) you will win. In addition to this, if you like/tolerate callback-based programming and you do not need uWSGI specific features, i find Tornado a great solution for the problem.

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.