[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Orbiter - a personal http app server
- From: Petite Abeille <petite.abeille@...>
- Date: Tue, 8 Feb 2011 20:28:24 +0100
On Feb 8, 2011, at 9:45 AM, Michal Kottman wrote:
>>> While we are at it, here are my very own 500 lines worth of dinky HTTP server... and it doesn't even need LuaSocket :P
>> Man, that is such cool code that I don't understand how it actually
>> works ;) In particular, how does it do the basic networking layer?
> Reading the source, it looks like it uses by default io.stdin and
> io.stdout, or anything that supports the :read() and :write() methods
> (i.e. sockets).
Right, HTTP.lua works in term of a subset of the file io API  so it doesn't concern itself with networking per se. Just with the HTTP protocol itself.
So it can be run directly from the terminal, avoiding the entire network stack altogether. Handy for development/debugging.
Or over a tcp wrapper such as D.J. Bernstein's tcpserver , leaving network management to these who know best :P
For example, this is how the online demo of Nanoki  runs:
exec bin/tcpserver -c 100 -qRHlOD 0 3388 bin/timelimit 60 bin/lua Nanoki.lua .
And of course, it can use LuaSocket as well  :)
HTTP[ '/' ] = function() return 'Hello world' end TCPServer( '127.0.0.1', 1080 )( HTTP )
The embedded server can be used directly, or in conjunction with something like nginx  to provide a pool of long running application instances.
> Does that mean that it can work cleanly with FCGI as a "sub-server"?
Perhaps. Never tried :)