Skip to content

Commit

Permalink
Check PORT in Makefile run
Browse files Browse the repository at this point in the history
Adding this because there's no error message when failed to start the load-balancer because of port in use

Also add HQ_SUBMIT_DELAY_MS for more stable performance
  • Loading branch information
LennoxLiu committed Apr 16, 2024
1 parent 67166b7 commit eff2e5a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@ load-balancer-files = LoadBalancer.cpp LoadBalancer.hpp ../lib/httplib.h ../lib/

build-load-balancer:
- g++ -O3 -Wno-unused-result -std=c++17 $(load-balancer-files) -o load-balancer -pthread

run-load-balancer:
if ! printenv PORT > /dev/null; then \
echo "PORT environment variable not set. Using default value 4242."; \
export PORT=4242; \
fi && \
export HQ_SUBMIT_DELAY_MS=100 && \
while nc -z localhost $$PORT; do \
read -p "Port $$PORT is already in use. Please enter a different port: " NEW_PORT; \
PORT=$${NEW_PORT:-$$PORT}; \
done; \
./load-balancer

0 comments on commit eff2e5a

Please sign in to comment.