descriptionluanode github mirror
homepage URLhttps://github.com/ignacio/LuaNode
repository URLhttps://github.com/ignacio/LuaNode.git
ownerhacxzuan@gmail.com
last changeThu, 24 Mar 2016 15:53:34 +0000 (24 12:53 -0300)
last refreshFri, 3 May 2024 21:29:00 +0000 (3 23:29 +0200)
content tags
add:
README.md

LuaNode

Build Status Build status License

Asynchronous I/O for Lua.

LuaNode allows to write performant net servers or clients, using an asynchronous model of computing (the Reactor pattern). You might have seen this model implemented in event processing frameworks like Node.js, EventMachine or Twisted. In fact, LuaNode is heavily based on Node.js, because I wanted to be able to do what Node.js does, but using Lua instead of JavaScript.

LuaNode is written using Boost.Asio. From its homepage:

Boost.Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.

That allows LuaNode to be cross-platform. It is mainly developed on Windows, but it is being tested also on Linux and OSX.

Hello, world

The following is the "hello world" of HTTP servers.

local http = require('luanode.http')

http.createServer(function(self, request, response)
   response:writeHead(200, {["Content-Type"] = "text/plain"})
   response:finish("Hello World")
end):listen(8124)

console.log('Server running at http://127.0.0.1:8124/')

process:loop()

To run the server, put the above code in a file test_server.lua and execute it with LuaNode as follows:

luanode test_server.lua

Then point your browser to http://localhost:8124/

You'll notice a striking resemblance with Node.js example server. In fact, I've aimed at keeping both, within reason, to be quite compatible. Code from Node.js can be easily rewritten from JavaScript into Lua, and with a few more tweaks, you can adapt code available today for Node.js.

Building

LuaNode can be compiled on Windows, Linux and OSX, using CMake. Although there are makefiles and projects for Visual Studio in the build folder, they are not really meant for general use. Currently, the recommended way to build is by using CMake 2.6 or above.

It is regularly built on:

LuaNode depends on the following:

Debian installation

If you already have Lua, OpenSSL and Boost installed, you can use CMake to build LuaNode (thanks to Michal Kottman). Just do:

If you do not want to or cannot use CMake, the following has been tested on Ubuntu Desktop 10.10 / Debian testing.

When compiling on ArchLinux, the last step is this:

Note: This installation procedure will be simplified in the future.

Mac OSX installation

Note: Installation was tested on OS X Lion 10.7.5, OS X Mountain Lion 10.8 and OSX Mavericks 10.9

If you don't have boost or cmake installed, you can use Homebrew:

Compile from sources with cmake:

Status

Currently, there's a lot of functionality missing. Doing a grep TODO should give an idea :D

Documentation

Sorry, I've written nothing yet, but you can get along following Node.js 0.2.5 documentation.

The two most glaring difference between Node.js and LuaNode are:

The unit tests provide lots of examples. They are available at the test folder.

Acknowledgements

I'd like to acknowledge the work of the following people or group:

License

LuaNode is available under the MIT license.

shortlog
2016-03-24 Ignacio BurgueñoUpdate [ci skip]master
2015-08-13 Ignacio BurgueñoCompile with VS 2015, OpenSSL 1.0.2d and Boost 1.5925/head
2015-06-26 Ignacio BurgueñoAppVeyor: Pin VS version to 2013 for the time being
2015-06-26 Ignacio BurgueñoUse OpenSSL 1.0.2c with appveyor
2015-06-26 Ignacio BurgueñoRework the Travis scripts and use default image in...
2015-04-24 Ignacio BurgueñoUpdate Readme due to new LuaRocks version [ci skip]
2015-04-24 Ignacio BurgueñoTest using LuaRocks 2.2.2
2015-04-22 Ignacio BurgueñoTest with Boost 1.58.0 and do not hardcode versions...
2015-04-09 Ignacio BurgueñoAdds MIT license badge [ci skip]
2015-04-09 Ignacio BurgueñoFix lunit's url in the README [ci skip]
2015-04-09 Ignacio BurgueñoMinor edits to README [ci skip]
2015-04-09 Ignacio Burgueño[ci] Use Docker infrastructure on Travis.
2015-03-27 Ignacio BurgueñoImproves build and makes it work in x64 arch
2015-03-23 Ignacio BurgueñoUse LuaRocks 2.2.1 in CI build
2015-03-20 Ignacio Burgueño[CI] Cleanup of AppVeyor integration
2015-03-20 Ignacio Burgueño[CI] Oh, the joys of cmd
...
tags
10 years ago v0.0.1
heads
8 years ago master
8 years ago appv
8 years ago test_apt
10 years ago travis_osx
10 years ago tls
12 years ago coroutines