HAProxy Enterprise Documentation 2.4r1

Program

When you add a program section, you enable the HAProxy Process Manager, which allows you to start external programs when HAProxy Enterprise starts.

Program configuration examples

In the following example, we run the echo program, which prints "hello, world". Each program keyword is followed by a label, such as echo, to differentiate it from others.

global
   master-worker

program echo
   command echo "hello, world"

When you restart HAProxy Enterprise, you can see that the echo command executed:

$ sudo systemctl restart hapee-2.4-lb

systemd[1]: Starting HAPEE Load Balancer...
hapee-lb[3330]: [NOTICE] 324/184322 (3330) : New program 'echo' (3351) forked
hapee-lb[3330]: [NOTICE] 324/184322 (3330) : New worker #1 (3352) forked
systemd[1]: Started HAPEE Load Balancer.
hapee-lb[3330]: hello, world
hapee-lb[3330]: [ALERT] 324/184322 (3330) : Current program 'echo' (3351) exited with code 0 (Exit)

A common way to use this feature is to start long-running programs that augment the load balancer functionality; therefore, it makes sense to tie them to the lifetime of the load balancer's process.

For example, you can start Stream Processing Offload Agent programs such as the Traffic Mirror agent:

global
   master-worker

program mirror
   command spoa-mirror --runtime 0 --mirror-url http://test.local

Note that all flags that follow the program's name are passed directly to the program.

Add user or group

You can also specify a user and group to use when executing the command:

global
   master-worker

program mirror
   command spoa-mirror --runtime 0 --mirror-url http://test.local
   user oca
   group users

Disable restarts

By default, HAProxy Enterprise stops and recreates child programs at reload. To disable this, add the no option start-on-reload directive to a particular program section:

global
   master-worker

program mirror
   command spoa-mirror --runtime 0 --mirror-url http://test.local
   user oca
   group users
   no option start-on-reload

See also

Process Manager


Next up

Dynamic-update
HAProxyConf 2022 - Call for papers