From beca53da3b1591b169e837ddc7543a90550b7ed1 Mon Sep 17 00:00:00 2001
From: SynaptiCAD User <sales@syncad.com>
Date: Thu, 27 Mar 2025 16:31:16 +0000
Subject: [PATCH] Don't hard-code the 'haf-world' docker-compose prefix in
 assisted startup. Reduce the amount of total memory assisted startup requires
 before creating a ramdisk to increase the chance that a 64G system will
 qualify.  Explicitly set a maxconn limit for haproxy to prevent errors when
 running on systems where max open file descriptors is set really high

---
 assisted_startup.sh | 4 ++--
 haproxy/haproxy.cfg | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/assisted_startup.sh b/assisted_startup.sh
index 2fcbb84..32d1617 100755
--- a/assisted_startup.sh
+++ b/assisted_startup.sh
@@ -274,7 +274,7 @@ else
         swap_location=$(swapon --show=NAME --noheadings)
 
 
-        if [[ $physical_memory -gt 60 && $free_memory -gt 30 && $NO_RAMDISK != 1 ]]; then
+        if [[ $physical_memory -ge 60 && $free_memory -gt 30 && $NO_RAMDISK != 1 ]]; then
             echo "There is more than 64 gigabytes of RAM. Mounting shared_mem..."
             if [ ! -d "/mnt/haf_shared_mem" ]; then
                 sudo mkdir /mnt/haf_shared_mem
@@ -403,7 +403,7 @@ while read -r line; do
         echo "Detected *PROFILE: Entered LIVE sync* in the output. Bringing down Docker Compose..."
         entered_livesync=1
         # Write Sync time to "haf.log" for tracking, as this log will get wiped on restart
-        docker logs haf-world-haf-1 | grep PRO > haf.log
+        docker compose logs haf | grep PROFILE > haf.log
         # Write max memory and swap usage to "haf.log" for tracking
         grep "max_mem=" startup.temp >> haf.log
         grep "max_swap=" startup.temp >> haf.log
diff --git a/haproxy/haproxy.cfg b/haproxy/haproxy.cfg
index 47310e5..5b5aa37 100644
--- a/haproxy/haproxy.cfg
+++ b/haproxy/haproxy.cfg
@@ -6,6 +6,14 @@ global
   presetenv SYNC_BROADCAST_BACKEND_SERVER api.hive.blog
   presetenv SYNC_BROADCAST_BACKEND_PORT 443
   presetenv SYNC_BROADCAST_BACKEND_SSL ssl 
+  # maxconn needs to be set to handle our maximum expected load.
+  # Let's say we want to handle 10000 calls/second.
+  # Most of our API calls will timeout after 3 seconds.  If we assume
+  # the worst case, where all of the calls take the full 3 seconds, we
+  # should expect 30000 calls in flight at any one time.  We'll round up
+  # to 32768.  In reality, the vast majority of calls should be handled
+  # in a few tens of milliseconds so this should be massive overkill.
+  maxconn 32768
 
 # DEFAULTS
 # do not put a defaults section here, the defaults section is included
-- 
GitLab