Start/Run Haproxy in foreground

run-haproxy-in-foreground

 

In this article we will explain how to start/Run HAproxy in foreground.
HAproxy is an open source software loadbalancer which is offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is suited for suited for very high traffic web sites and powers quite a number of the world’s most visited ones. Ove the years it has become the default standard software load balancer, is now shipped with most mainstream Linux distributions.
With default configuration HAproxy runs as a deomon ( in background) which is good for most of the use cases. But sometimes we require it to start in foreground , one use case case is running haproxy on Docker, where the application has to keep running in foreground. Let us see how to start/run HAproxy in foreground .

Start/run HAproxy in foreground

You can see haproxy command line options using the command “haproxy –help”

The¬†command line flag “-D” will launch HAproxy in background or ¬†as a daemon. When you start HAproxy using command line options make sure you don’t use the option “D”

In the haproxy configuration file , you will see an option “daemon”, if you keep it commented HAproxy will not go to daemon mode and start on foreground
Sample config snippet is below

You can see that “deamon” option is commented. Now if we start haproxy

You can see that HAproxy started on foreground and printing debug logs to console.

Leave a Reply

Your email address will not be published. Required fields are marked *