From f1d9cc0255035d7cb3c8528b30c62a2fb6651af9 Mon Sep 17 00:00:00 2001 From: Dinko Korunic Date: Wed, 15 Jun 2022 08:43:33 +0000 Subject: [PATCH] BUG/MINOR: Add -m to HAProxy arguments to set memory limit to 2/3 of RAM --- fs/etc/services.d/haproxy/run | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/etc/services.d/haproxy/run b/fs/etc/services.d/haproxy/run index 1d3862f2..a3da5aef 100644 --- a/fs/etc/services.d/haproxy/run +++ b/fs/etc/services.d/haproxy/run @@ -1,4 +1,5 @@ -#!/usr/bin/execlineb -P +#!/usr/bin/with-contenv sh -with-contenv -/usr/local/sbin/haproxy -W -db -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/haproxy-aux.cfg +MEMLIMIT=$(free -m | awk '/Mem:/ {print int($2 * 2 / 3)}') + +exec /usr/local/sbin/haproxy -W -db -m "${MEMLIMIT}" -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/haproxy-aux.cfg