Hi all,
I spent some time tonight adding mobwrite into my tornado-based
application. (Never heard of the FriendFeed Tornado web server? See
http://www.tornadoweb.org/)
A tornado-based mobwrite is interesting because:
- you can run it as part of another tornado app without needing a
separate process and port
- eliminates the needs for threads
- runs a web server on its own port without needing a weird proxy service
- makes it theoretically possible to do a comet-style web service
(using HTTP "long polling" so that updates can be delivered to all
clients instantly, instead of after a poll delay). I didn't implement
this yet, however.
SUGGESTION: because tornado itself is quite small, it's plausible to
import it right into your project, then get rid of all the other web
proxy services included in mobwrite, which turn out to be rather buggy
and largely non-functional. (And I should know, because I fixed some
of the bugs in the process of figuring this out :)) This would
greatly reduce your maintenance burden, since you'd only need to
support exactly one daemon. This also obsoletes the mobwrite-nginx
service that I see someone wrote awhile back; nginx can already proxy
straight to a local HTTP server. (In fact, that's how tornado is
normally used.)
You can grab a copy of my repo or any of my individual patches here:
http://github.com/apenwarr/mobwrite/commits/tornado-daemon
Brief list of changes:
- fix q.py when running as a plain CGI; it had a reversed 'if'
condition that made it totally fail.
- fix mobwrite_core.js when running in POST mode; it was missing a
trailing newline and didn't work at all. (NOTE: I didn't update
compressed_form.js. Since this is a generated file, why is it checked
into the repo? It's error prone this way, and there seem to be no
script to regenerate it.)
- mobwrite_daemon: make it usable inside other kinds of daemons, not
just a telnet server.
- mobwrite_daemon: make it find its files even if the cwd isn't always
mobwrite/daemon at startup time.
- mobwrite_tornado: a new daemon that runs on tornado and serves http directly.
- __init__.py: make it so other people can include the daemon's files
without twiddling their python library path.
Not sure how you guys would like patches to be packaged. You can give
me access to the svn project and I could just commit them there, or
you could pull them out of my git and apply them yourself, or I could
send actual patch files.
Have fun,
Avery