This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `/_haproxy_getconfig` returns the HAProxy config as it was at the time of process initialization.
- Loading branch information
1 parent
491f777
commit 0645ffd
Showing
5 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- A simple Lua script which serves up the HAProxy | ||
-- config as it was at init time. | ||
|
||
function read_config_file(cmdline) | ||
local found = false | ||
local filename = '' | ||
for s in string.gmatch(cmdline, '%g+') do | ||
if s == '-f' then | ||
found = true | ||
elseif found then | ||
filename = s | ||
break | ||
end | ||
end | ||
|
||
local f = io.open(filename, "rb") | ||
local config = f:read("*all") | ||
f:close() | ||
return config | ||
end | ||
|
||
function load_config() | ||
local f = io.open('/proc/self/cmdline', "rb") | ||
local cmdline = f:read("*all") | ||
f:close() | ||
return read_config_file(cmdline) | ||
end | ||
|
||
core.register_init(function() | ||
haproxy_config = load_config() | ||
end) | ||
|
||
core.register_service("getconfig", "http", function(applet) | ||
applet:set_status(200) | ||
applet:add_header("content-length", string.len(haproxy_config)) | ||
applet:add_header("content-type", "text/plain") | ||
applet:start_response() | ||
applet:send(haproxy_config) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters