How can I serve a WSGI Python app using Mongrel2?
Asked Answered
J

4

5

This is an attempt to discover a canonical answer for something that seems to be hard to Google for right now. I am writing a web app in Pyramid, and I have the luxury of deciding what my server stack will look like. I've heard very good things about Mongrel2, and would like to try using it to serve my app. However, I can't figure out from the Mongrel2 manual and Google searches, how to connect Mongrel2 to a WSGI app. Do I have to roll my own, or are there existing solutions to this problem?

Joscelin answered 14/10, 2011 at 22:38 Comment(0)
J
6

In pursuit of a canonical answer, here are the WSGI handlers that I've found while looking for a way to get Mongrel2 to serve a WSGI app. Right now, it looks like wsgid is the best bet for Django users, but terminally flawed for others, and the alternatives are flawed.


  • The wsgid project is not yet at 1.0, but there are a lot of things that are usable before 1.0. It seems to have an active community around it, which is a recommendation.
  • The m2wsgi handler appears to mostly be one guy's project, but it looks to be alive, and "I started writing foo because I tried bar and baz and they didn't quite solve my problem" is a good place to start, and its feature-list looks good.
  • The Mongrel2-WSGI-Handler project on GitHub hasn't had a commit in over a year, so while it might be functional, I'm a little wary of it.
  • The mongrel2_wsgi project on BitBucket also hasn't had a commit in over a year, so it doesn't look like a great candidate either.
  • Brubeck is an entire web framework built on Mongrel2 and Python, which looks interesting.

Discussions and posts elsewhere about this topic:

Joscelin answered 19/10, 2011 at 17:14 Comment(0)
C
3

There is this post I wrote that talks about how to setup a mongrel2 with wsgid to run your WSGI app. It's here: http://daltonmatos.wordpress.com/2011/11/06/deploying-your-django-application-with-mongrel2-and-wsgid/

Conscript answered 11/11, 2011 at 0:52 Comment(1)
Thanks, Dalton! I added that link to the list in the canonical answer.Joscelin
C
2

You need to use a Mongrel 2 handler that can serve a WSGI application. Basically something that translates the messages from a mongrel2 zeromq socket into a wsgi environ. There are several of these, I've used m2wsgi successfully in the past, but I think wsgid looks very promising as well.

Creaturely answered 17/10, 2011 at 1:6 Comment(1)
Ah, okay - I think that "handler" was the piece of terminology that I was missing, because once I start looking for a "handler," things get easier. Thank you.Joscelin
C
2

Specifically about wsgid, you will probably need to tell it to load a generic WSGI application. You can know more about how to do it in the docs: Loading a generic WSGI Application, but implementing an AppLoader would not be that difficult.

If you need any other help you can send an email to the mailing list, will be a pleasure to help.

Conscript answered 18/10, 2011 at 20:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.