Skip to content

Commit

Permalink
working locally with test mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
the-dusky committed Dec 21, 2024
1 parent aa42708 commit 25c2217
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
21 changes: 16 additions & 5 deletions docker/scripts/mgpu
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,33 @@ restart_service() {
# Wait for port to be released (up to 30 seconds)
local port=$((8188 + gpu_id))
local wait_time=0

# First check if process is still running
local pid
pid=$(lsof -t -i ":$port" 2>/dev/null)
if [ -n "$pid" ]; then
log "Process still using port $port (PID: $pid), killing..."
kill -9 "$pid"
sleep 2
fi

# Double-check port is free
while lsof -i ":$port" >/dev/null 2>&1; do
if [ "$wait_time" -ge 30 ]; then
log "ERROR: Port $port still in use after 30 seconds"
log "Current port status:"
lsof -i ":$port" 2>&1 | while read -r line; do log " $line"; done
return 1
fi
log "Waiting for port $port to be released..."
sleep 2
wait_time=$((wait_time + 2))
done

# Additional wait to ensure clean shutdown
sleep 2

# Start the service
# Start the service with the correct port
export COMFY_PORT="$port"
if ! start_service "$gpu_id"; then
log "ERROR: Failed to restart service for GPU $gpu_id"
log "ERROR: Failed to start ComfyUI service for GPU $gpu_id"
return 1
fi

Expand Down
11 changes: 7 additions & 4 deletions docker/scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ verify_services() {

# Test NGINX auth separately from service
log "Testing NGINX auth on port 3188..."
if ! curl -I -s --fail -u "$COMFY_AUTH" "http://localhost:3188/"; then
if ! make_auth_request "http://localhost:3188/system_stats"; then
log "ERROR: NGINX auth test failed"
log "Curl verbose output:"
curl -v -I -u "$COMFY_AUTH" "http://localhost:3188/" 2>&1 | while read -r line; do log " $line"; done
Expand All @@ -655,6 +655,7 @@ verify_services() {

# 2. Verify ComfyUI Services
log "=== Verifying ComfyUI Services ==="
log "How many GPUs: $NUM_GPUS"
if [ "$NUM_GPUS" -eq 0 ]; then
# CPU mode
log "Checking CPU mode..."
Expand Down Expand Up @@ -776,8 +777,8 @@ setup_preinstalled_nodes() {

setup_auth() {
if [ -n "$SERVER_CREDS" ]; then
# Just base64 encode, curl will add "Basic " prefix
COMFY_AUTH="$SERVER_CREDS"
# Add "sd:" prefix and base64 encode
COMFY_AUTH=$(echo -n "sd:$SERVER_CREDS" | base64)
else
log "WARNING: SERVER_CREDS not set, authentication may fail"
fi
Expand All @@ -788,7 +789,9 @@ make_auth_request() {
local auth_opts=""

if [ -n "$COMFY_AUTH" ]; then
auth_opts="-u '$COMFY_AUTH'"
# Decode base64 credentials for curl
local decoded_creds=$(echo "$COMFY_AUTH" | base64 -d)
auth_opts="-u '$decoded_creds'"
fi

if [ "$2" = "verbose" ]; then
Expand Down

0 comments on commit 25c2217

Please sign in to comment.