Do you think uWSGI deserves a place in the official django documentation ?
I think it should because it's easier, safer, faster and more secure
than flup or mod_wsgi. Also, it made my sysadmin life really easy and
that's something cool to share with the community.
In this case, please consider the attached draft
(django/docs/howto/deployment/uwsgi.txt): it's not perfect and
probably not commitable as-is, but I am ready to listen to feedback
and improve it. Otherwise it'll just make another blog post.
What do you think ?
Cheers
+1. More docs didn't hurt anybody. At least while there is someone to
maintain them.
>
> What do you think ?
>
My first impression is that you're focusing too much on all those
switches. That section got me totally lost. That should be simplified.
Also, do I really need to type all that stuff? I probably won't be
doing that on production, so showing how to place it in a
configuration file would be better.
I would also drop the whole "advantages" section. The purpose of the
page is to show how to deploy a Django app on uWSGI, not compare it
against other solutions. You also mention some features, but never
show how to enable/use them which is confusing.
PS. Do you think having a `runuwsgi` command similar to `runfcgi`
would be useful ?
--
Łukasz Rekucki
I have made a tiny runuwsgi implementation:
http://projects.unbit.it/uwsgi/browser/contrib/runuwsgi.py
it tries to autoload plugins and spawn the embedded http router/proxy on a default port.
You can specify the socket=ADDR option to disable the http part and bind the server on a uwsgi socket (for directly pointing your webserver to it)
It run multithreaded (8 threads) but i suppose that this could be another configurable option.
It requires a 0.9.7.2 uWSGI version (released in a couple of days) or the current mercurial tip.
I hope it can be useful
--
Roberto De Ioris
http://unbit.it
> --
> You received this message because you are subscribed to the Google Groups "Django developers" group.
> To post to this group, send email to django-d...@googlegroups.com.
> To unsubscribe from this group, send email to django-develop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
>
>
I think he is referring to the various included jailing systems (chroot,
linux namespaces, posix capabilities...) because if we are talking about
protocols there are no really differences between uwsgi and FastCGI, both
are unsecure by-design :)
> I believe that running manage.py for production deployments is "not
> way to go", as it has been noted by django devs previously.
> What purpose would runuwsgi command serve ?
I see it as a way to easily use the embedded uwsgi module/api before going
into production. If a user want to use something like the uWSGI timer/cron
system
http://projects.unbit.it/uwsgi/wiki/DjangoTimers
http://projects.unbit.it/uwsgi/wiki/CronInterface
it can just start coding without passing for all the stack configuration.
Remember that you do not need those file anymore:
[uwsgi]
env = DJANGO_SETTING_MODULE=mysite.settings
chdir = <django_app_directory>
module = django.core.handlers.wsgi:WSGIHandler()
...
...
Or you can do magic with placeholder like this:
[uwsgi]
my_django_app = mysite
env = DJANGO_SETTING_MODULE=%(my_django_app).settings
chdir = /apps/%(my_django_app)
module = django.core.handlers.wsgi:WSGIHandler()
(obviously this rules apply to xml,yaml,ldap,command line and so on...)
> uWSGI_ supports configuration through:
>
> * command line switches
> * ini files
> * xml files
yaml is supported too and you should mention environment variables, they are
used a lot on already available *BSD init scripts
Probably i would add a section about massive hosting of applications using
the Emperor (The Emperor doc is probably the only good one of all the
uWSGI project as it is not written by me :) )
http://projects.unbit.it/uwsgi/wiki/Emperor
One of the most-loved (by me too) feature of mod_wsgi is its
virtualhosting capability
tied-in with apache. uWSGI in the past forced you to manually manage a
instance for every app or use the PITA (but funny and hacky)
multiple-interpreters-way. The Emperor solves this problem elegantly and
with a lot of attention about clouding/hosting platforms.
>
> Starting the server
> -------------------
>
> Starting an uWSGI_ server is the role of the system administrator,
> like
> starting the Web server. It is *not* the role of the Web server to
> start the
> uWSGI_ server. This means:
>
> * the uWSGI_ server can be restarted or reloaded independently from
> the Web
> server,
> * it is the role of the system administrator to make uWSGI_ to start
> on boot
> or reboot: either through tools like supervisor or daemontools,
> either
> directly at init level in a file like /etc/rc.local or /etc/conf.d/
> local
Nothing to say against this, but Cherokee (as an example) manages the
uWSGI processes itself (it is an exception to the rule, i do not know if
it is worth mentioning it).
>
> Patching the daemon
> -------------------
>
> One of the great advantages of uWSGI_ is its ability to gradually
> restart each
> worker without loosing any request. For example, uWSGI_ can be
> signaled that
> worker should reload the code after handling their current request (if
> any)::
>
> kill -HUP `cat /tmp/project-master.pid`
You can gracefully reload (in 0.9.7 tree) simply touching a file with
the --touch-reload = <file> option and (probably more important) you can
reload from the app itself using uwsgi.reload()
>
>
> Tipical gotchas:
>
> * if the socket is a file: the Web server process should have read,
> write and
> execute permissions on the socket file
you should mention the --chmod-socket option here
> * uWSGI_ won't remove the socket and pidfile when it is interrupted,
here --vacuum option should be reported, but i will put enphasis on the
inhability to remove socket/pidfile if you "kill -9" the uWSGI stack
If you have some doubt please ask me or the official uWSGI mailing-list i
know that uWSGI official docs are really bad and not synced with the
current code :P
I'm a little confused by this sentiment. Why is it Django's role to
provide full documentation for mod_wsgi (or any other deployment
interface, for that matter)? If people are complaining that mod_wsgi
is too hard to use, why is that a failure of *Django's* documentation?
Django isn't the sole arbiter of all documentation. We are in a
position to document Django. We are in a position to point out the
unique requirements that Django may have (for example, what needs to
be in the system path and environment). We can -- and do -- link to
the official documentation for mod_wsgi.
At some point, the issue with deploying Django under X has less to do
with Django, and more to do with the eccentricities of X. That's the
point at which, IMHO, it ceases to be Django's responsibility to
provide documentation. I don't think it's Django's place to document
mod_wsgi any more than it's Django's place to document MySQL or
SQLite. We provide the detail to explain the Django-specific friction
points that exist, but beyond that, it's up to those external (to
Django) libraries to provide adequate documentation for their own
configurations.
> To me this should extend to ensuring that interfaces in the framework make
> it easy and predictable. It is a said state of affairs though that pretty
> well all the Python web frameworks give minimal time to ensuring that the
> experience of a user as far as hosting it is as simple as possible and why
> every framework is so different and don't use some sort of common defining
> mechanism for an entry point.
Again, I'm confused here -- to my reading, this "common defining
mechanism" is what WSGI is supposed to be.
You won't get any argument out of me that Django has some quirks that
makes deployment harder than it should be -- for example, the path
munging problems that you've blogged about in the past. You won't get
any argument out of me that these issues should be addressed.
The reason we spend "minimal time" addressing these problems is that
in the grand scheme of things, deployment pain is quite far down the
list of problems that we have. Yes, Django has deployment quirks. Yes,
this makes it harder for absolute beginners to get started. However,
once you understand those quirks (as any non-beginning Django user
must do), deployment simply isn't that big a problem.
I completely agree that deploying Django could be *better*, but like
it or not, the status quo *works*, and the 'itch' that would cause
someone to address this issue is a relatively minor annoyance. On the
other hand, issues like logging, handling of static files, controlling
cascading behavior during deletion, i18n and l10n are problems that
are real, current, and affect *every* Django user, be they novice or
master. The incentive to work on these issues (and I've just picked
the ones we addressed in 1.3) is much higher.
If someone wants to take a swing at addressing these Django-specific
deployment issues, I fully support that. However, that doesn't just
mean pointing out the problems that exist -- we already know they
exist. It means providing a concrete patch that fixes those problems,
or at least can be used as a starting point for further discussion.
Yours,
Russ Magee %-)
I have asked anything, other users spawned this thread, and as the main
uWSGI author i am doing suggestions/corrections.
On Sat, Apr 9, 2011 at 2:15 PM, Graham Dumpleton
<graham.d...@gmail.com> wrote:
> To be blunt, you are actually asking a lot for them to host detailed
> documentation on uWSGI integration on the Django site for every possible way
> it can be setup. I haven't even managed to get much more than minimal setup
> instructions for mod_wsgi into the official Django documentation.
> I believe you will find that they don't really believe it is for them to be
> providing extensive documentation on particular hosting mechanisms, or at
> least they don't have the time. Personally I do find that stance a bit odd
> as they should be striving to at least ensure that it is as painless as
> possible for users to get it going on at least the mainstream hosting
> methods to combat the accusations that it is too hard. As such, the minimal
> documentation they provide at the moment is quite often not enough.I'm a little confused by this sentiment. Why is it Django's role to
provide full documentation for mod_wsgi (or any other deployment
interface, for that matter)?
If people are complaining that mod_wsgi
is too hard to use, why is that a failure of *Django's* documentation?
> To me this should extend to ensuring that interfaces in the framework make> it easy and predictable. It is a said state of affairs though that pretty
> well all the Python web frameworks give minimal time to ensuring that the
> experience of a user as far as hosting it is as simple as possible and why
> every framework is so different and don't use some sort of common defining
> mechanism for an entry point.Again, I'm confused here -- to my reading, this "common defining
mechanism" is what WSGI is supposed to be.
Graham -- I've been singularly impressed by the way you offer to help
out people with their Django deployment problems, even when they seem
to afflicted with a clinically inability to read instructions or take
a systematic approach to solving problems. I don't know if you've got
the impression that your efforts aren't appreciated -- from me, at
least, they most certainly are, and I'm sure the rest of the core team
would join me in that sentiment. Thank you for everything you have
done in this regard.
We've also clearly been spoiled by the existence of mod_wsgi's docs.
To be completely honest, I hadn't even looked at Django's mod_wsgi
docs for some time, and I was quite surprised at how terse they were
when I actually went and took a look. I completely agree that there is
room for improvement here. When it comes to documentation, there
always is; but in this case, I'd argue we're at the bare minimum
acceptable level right now. We've obviously been leaning on the "see
the mod_wsgi docs" link for far too long.
As for your pain points, and Django rejecting your suggestions -- all
I can say is that there is a very important difference between:
a) We haven't implemented your change,
b) We agree the problem you describe exists, but not on the solution
you propose,
c) We have rejected your change.
d) We aren't aware that you think a change needs to be made
Problems like sys.path munging fall into category (a). I completely
agree that this *is* a problem. I completely agree that it *should* be
fixed. The only issue is resourcing and prioritization. Unfortunately,
fixing this particular problem is worse than trying to untangle
Christmas tree lights, and because there's a fully functional
workaround (a.k.a. "learn how it works from your first experience"),
we haven't got people clamoring to fix the issue.
The handling of LOGIN_URL/SCRIPT_PREFIX is an example of category (b),
The last time this came up [1] it was in response to feedback that
Jacob had given, and while I backed Jacob's decision, I agreed that
something needed to be done as a documentation task. There was also an
ongoing discussion that suggested some alternate approaches to the
problem. However, this discussion never went anywhere -- it never
resulted in a patch, or even a ticket for the required documentation
issue. As a result, a problem that starting in category (b) ended up
in category (a) due to a lack of driving attention -- it just fell
through the cracks.
From a quick survey of your involvement on django-dev for the last
year or so, I can't find any examples of category (c). If I'm wrong on
this, please let me know.
That leaves us with (d). Your involvement helping debug the world's
WSGI problems does put you in an almost unique position to point out
the specific problems with Django's documentation, especially with
newcomers. However, I could only find 1 ticket in Django's tracker
that you've opened yourself [2] -- #11229, which was closed (with the
requested change to documentation being made) within 2 months of being
opened. If we're not implementing the changes you think need to be
made, I put it to you that one of the reasons is that we're simply not
aware of the changes you think need to be made.
Now, this may be because the baseline document is so woeful, and
making specific suggestions on a document that is bad to start with
doesn't serve much purpose. So, let me propose a course of action to
remedy this.
If you would rather that Django takes over management of the "Django
under mod_wsgi" document that is currently hosted on mod_wsgi's site,
I will commit to getting a version of that document integrated into
Django's documentation as an updated version of our mod_wsgi
documentation. Let me know if you want to do this, and I'll open a
ticket and make it happen.
Beyond that, if you have specific suggestions for how Django's
documentation should be improved, I can only ask that you open a
ticket. If you provide draft updates as a patch, that will help
lubricate the process, but even if you don't -- tickets are the only
reliable way we have for getting suggestions integrated into Django.
Once again -- thanks for all the work you've done, both on mod_wsgi in
general, and in supporting Django users using mod_wsgi. It's most
certainly appreciated. Even though you're not part of the Django core
team, your work is a vital part of the Django ecosystem (not to
mention the broader Python web ecosystem); I don't want to alienate
someone who plays such an important part of Django's continued
success.
[1] http://groups.google.com/group/django-developers/browse_thread/thread/fa3661888716f940
[2] http://code.djangoproject.com/query?status=assigned&status=closed&status=new&status=reopened&reporter=grahamd
Yours,
Russ Magee %-)
Seems very good to me, the only thing that i would really change is --home
to --chdir
as --home is used for virtualenv. In my experience using --chdir with django
causes less headache to users.
Probaly you could add the same example written with a ini file too, only
to show users that they not need to write such huge command lines :)
Another (maybe important) note to add is that uWSGI does not run on Windows