blob: 9ea8e334836b35ab10e758b3233951276191d4b7 [file] [log] [blame]
William Lallemand039cc082021-09-24 19:02:50 +02001
2local vtc_port = 0
3
4core.register_service("fakeserv", "http", function(applet)
5 vtc_port = applet.headers["vtcport"][0]
6 core.Info("APPLET START")
7 local response = "OK"
8 applet:add_header("Server", "haproxy/webstats")
9 applet:add_header("Content-Length", string.len(response))
10 applet:add_header("Content-Type", "text/html")
11 applet:start_response()
12 applet:send(response)
13 core.Info("APPLET DONE")
14end)
15
16local function cron()
17 -- wait for until the correct port is set through the c0 request..
18 while vtc_port == 0 do
19 core.msleep(1)
20 end
21 core.Debug('CRON port:' .. vtc_port)
22
23 local httpclient = core.httpclient()
William Lallemand746e6f32021-10-06 10:57:44 +020024 local response = httpclient:get{url="http://127.0.0.1:" .. vtc_port}
William Lallemand039cc082021-09-24 19:02:50 +020025
26 core.Info("Received: " .. response.body)
27end
28
29core.register_task(cron)