Installing additional LUA modules into Redis

luaredis

I'm trying to get Redis to allow EVAL (http://redis.io/commands/EVAL) to make HTTP requests.

Two modules: LuaCURL and Luasocket give this ability. The Redis source code has a directory with additional modules (such as cjson) http://download.redis.io/redis-stable/deps/lua/src/, I tried adding luacurl.c but I recieved error after error. I have managed to compile it enabling os.execute – by editing scripting.c – which allows me to run the curl command but that is a bad solution.

How do I compile HTTP requests in Redis's Lua?

Presumably the easiest way to do this would to be have a standalone luasocket.so file, but I'm not sure how to do that.

Best Answer

No worries, all I required was a nights sleep to have a fresh mind.

I downloaded http://files.luaforge.net/releases/luacurl/luacurl and move the luacurl.c into the /deps/lua/src/ folder and edited line 23 from

#include <lauxlib.h>

to

#include "lauxlib.h"

and then in /deps/lua/src/Makefile (Lua's makefile, not Redis's) go to line 30 and find

lua_cjson.o

add "luacurl.o" spaced next to it like so

lua_cjson.o luacurl.o

and then in /src/Makefile (Redis's makefile, not Lua's) change line 54 from

FINAL_LIBS=-lm

to

FINAL_LIBS=-lm -lcurl

Finally, make sure you have installed "yum install curl-devel" and then compile it.

Keep in mind that no other client can execute commands whilst the server is busy with Lua scripts.

Related Topic