Reshma,

On 5/26/21 4:44 PM, reshma r wrote:
not). There is a requirement that the configuration file may be changed
from an external portal. So whenever a change is made in the portal I would
like to update my configuration file accordingly. To do this, I am making a
socket call which periodically checks whether the portal has been changed
(from within haproxy action). If so I must write the updated values to the
file and it seems I cannot write to a file inside lua action so this is
where I am stuck. To me, It sounds like this cannot be achieved and I must
drop the idea of changing the file from the portal.

You should implement this in a dedicated sidecar process that checks the portal API and on a change writes the updated configuration file and then either updates the state within the running HAProxy process using the stats socket (e.g. using 'set map' [1] or 'set var' [2]) or reloads HAProxy depending on your exact requirements.

Just because you can do a lot of stuff within HAProxy using Lua doesn't mean that you should or that it's the best solution :-)

Best regards
Tim Düsterhus

[1] https://cbonte.github.io/haproxy-dconv/2.4/management.html#9.3-set%20map
[2] https://cbonte.github.io/haproxy-dconv/2.4/management.html#9.3-set%20var

Reply via email to