By Zed A. Shaw

Mongrel2 v1.4 Out With Fun BBS Demo

UPDATE: Download links were broken, now they're fixed.

It's been about 2 weeks since the last release, and this one's got a lot of fixes for tons of bugs, a completely redesigned IO buffering system, support for XML or JSON sockets, and a cool BBS demo in Lua.

Go grab it at http://mongrel2.org/home#download and follow the GettingStarted docs to get up and running.

Here's what's changed (from almost 250 commits):

  • JSON or XML routing can be used for messages to a socket. JSON is routed with @blah and XML with the root tag
  • Optionally set the raw_handler=1 flag in Handler() and it won't base64 the results. This is for newer flash clients that don't need this.
  • Fixes for various m2sh config loading problems.
  • Redesigned IO buffering that works with files, sockets, or SSL and is a kind of "half-ring-buffer" should speed things up and reduce ram copying during parsing, and also make XML, JSON, or HTTP play nice together.
  • New commands in the control port: help, stop, terminate. You can now manage Mongrel2 without PID files.
  • Generally cleaned up all debug printing so you get less junk in the error.log.
  • Tons of tests in tests/system_tests that I'm actively using to thrash mongrel2.
  • Memory leaks and errors fixed galore.
  • Access logging is now sent to a 0mq thread that does it lazy and doesn't block your mongrel2 process. Future versions will let you point this 0mq access log at anything you want.
  • Lots of code cleaning and auditing, this is an ongoing habit from now on.
  • A fun BBS written in Lua using mongrel2-lua and redis that is accessible from a simple Python command line client. Look in examples/bbs/ and I'll be blogging about it soon.

Things that are still broken:

  • SSL, the IOBuf code sort of broke this, but hopefully nobody was using it yet.
  • Performance. getaddrinfo is killing us on proxying, IPv6 lookups are slow as dirt, and generating payloads for handlers uses a ton of string/memcpy operations. To name a few.

Grab it and try it and report any errors you have. Thanks!

BBS DEMO

In order to test out this new JSON and XML code I thought up a fun little project where I build a BBS that accessible from a command line client with a raw socket, and from a browser using the same protocol. The idea is to show that Mongrel2 can be used to implement entire async services that don't even use the browser or HTTP. A BBS would also be fun and let me try out some cool Lua coroutine ideas I've had.

I started playing with Lua and Josh Simmons mongrel2-lua handler bindings. I must say Josh did a very nice job. I learned a ton of Lua this week from his code and from a couple books. After getting an understanding of it all I sat down and wrote the BBS.

Over the weekend I'm going to blog heavily about how I build the Lua BBS code, the good and bad parts of it, and lay out some ideas it has given me for new kinds of services architectures.

In the meantime though, try it out yourself. You can just grab this little Python script, save it to client.py and then run:

python client.py mongrel2.org 80

Yes, this is connecting directly to port 80 and using a completely different protocol than HTTP to talk to a Lua backend that implements an async BBS without you knowing it. It's also a lot of fun. Leave me a message, I'm zed.

For those of you too young to know what a BBS is, you can read about them on Wikipedia.

If you want to look at the code before I blog about it, it's in the fossil under examples/bbs. You'll need redis to use it.