Hi list,
While waiting for an article about Lua development in HAProxy, I post
one of my debug tools.
It is procided as is without doc except the following lines.
I suppose that the guy which do scripting knows the PHP print_r or the
perl Data::Dumper(), so I wrote an Lua print_r. It try to show complex
structs.
The usage is simply:
require("print_r")
print_r(txn)
Two facultative parameter exists:
print_r(txn, color, display)
color can be true or false, it activates or deactivate the color for
ANSI compatible terminal. It is activated by default
display is a function which took a string as parameter and must be
display it. By default,the string is display on the standard ouput.
You must start HAProxy in foreground without the option quiet.
A simple example with the file test.lua:
require("print_r")
core.register_action("do-nothing", { "tcp-req", "http-req" }, function (txn)
print_r(txn)
end)
Start haproxy, use the action do-nothing, and send request. There is
the minimal configuration file:
global
log 127.0.0.1 local0
lua-load lua1.lua
listen lst
bind *:10001
mode http
http-request lua.do-nothing
It will be display the full tree of the object txn, also with the
metatables. You will see all the converter and sample fetches
function, all the methods for manipulating http, ... I join a
screenshot :)
Enjoy, and don't hesitate to do comments
Thierry
While waiting for an article about Lua development in HAProxy, I post
one of my debug tools.
It is procided as is without doc except the following lines.
I suppose that the guy which do scripting knows the PHP print_r or the
perl Data::Dumper(), so I wrote an Lua print_r. It try to show complex
structs.
The usage is simply:
require("print_r")
print_r(txn)
Two facultative parameter exists:
print_r(txn, color, display)
color can be true or false, it activates or deactivate the color for
ANSI compatible terminal. It is activated by default
display is a function which took a string as parameter and must be
display it. By default,the string is display on the standard ouput.
You must start HAProxy in foreground without the option quiet.
A simple example with the file test.lua:
require("print_r")
core.register_action("do-nothing", { "tcp-req", "http-req" }, function (txn)
print_r(txn)
end)
Start haproxy, use the action do-nothing, and send request. There is
the minimal configuration file:
global
log 127.0.0.1 local0
lua-load lua1.lua
listen lst
bind *:10001
mode http
http-request lua.do-nothing
It will be display the full tree of the object txn, also with the
metatables. You will see all the converter and sample fetches
function, all the methods for manipulating http, ... I join a
screenshot :)
Enjoy, and don't hesitate to do comments
Thierry