HAProxy can either be started manually or using a service managed by systemctl. In this recipe, we shall we how the starting and stopping of the HAProxy service can be managed.
Getting ready...
In order to start or stop HAProxy, we should have already performed the steps in the following two recipes that have already been discussed earlier in this chapter:
- Installing HAProxy on Linux servers
- Creating an HaProxy configuration file
How to do it...
The following are the steps to start and stop the HAProxy service:
- To start the HAProxy service using systemctl, we could simply run the following command:
$ sudo systemctl start haproxy
- To ensure that the HAProxy service automatically starts upon a server reboot, we could enable the auto start for the HAProxy service using the following command:
$ sudo systemctl enable haproxy
- To start HAProxy manually, we could use the following command:
$ haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid...