2024-07-01 15:57:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Exit immediately if a command exits with a non-zero status
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Function to print colorized feedback
|
|
|
|
print_feedback() {
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${GREEN}[ComfyUI Startup]:${NC} $1"
|
|
|
|
}
|
|
|
|
|
2024-07-27 11:02:51 +02:00
|
|
|
# Function to run rsync with progress bar and optimizations
|
2024-07-01 15:57:52 +02:00
|
|
|
rsync_with_progress() {
|
2024-07-27 11:02:51 +02:00
|
|
|
rsync -aHvx --info=progress2 "$@"
|
2024-07-01 15:57:52 +02:00
|
|
|
}
|
|
|
|
|
2024-07-13 20:19:26 +02:00
|
|
|
# Check for required commands
|
2024-07-27 11:02:51 +02:00
|
|
|
for cmd in rsync; do
|
2024-07-13 20:19:26 +02:00
|
|
|
if ! command -v $cmd &> /dev/null; then
|
|
|
|
echo "$cmd could not be found, please install it."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2024-07-27 11:02:51 +02:00
|
|
|
LOG_FILE="/workspace/comfyui.log"
|
|
|
|
|
2024-07-01 15:57:52 +02:00
|
|
|
print_feedback "Starting ComfyUI setup..."
|
|
|
|
|
|
|
|
print_feedback "Syncing virtual environment..."
|
|
|
|
rsync_with_progress /venv/ /workspace/venv/
|
|
|
|
|
|
|
|
print_feedback "Activating virtual environment..."
|
2024-07-27 11:02:51 +02:00
|
|
|
export VIRTUAL_ENV="/workspace/venv"
|
|
|
|
export PATH="$VIRTUAL_ENV/bin:$PATH"
|
2024-07-01 15:57:52 +02:00
|
|
|
source /workspace/venv/bin/activate
|
|
|
|
|
|
|
|
export PYTHONUNBUFFERED=1
|
|
|
|
|
|
|
|
print_feedback "Syncing ComfyUI files..."
|
2024-07-27 11:02:51 +02:00
|
|
|
rsync_with_progress /ComfyUI/ /workspace/ComfyUI/
|
2024-07-01 15:57:52 +02:00
|
|
|
|
|
|
|
print_feedback "Creating symbolic links for model checkpoints..."
|
|
|
|
ln -sf /comfy-models/* /workspace/ComfyUI/models/checkpoints/
|
|
|
|
|
|
|
|
print_feedback "Changing to ComfyUI directory..."
|
|
|
|
cd /workspace/ComfyUI
|
|
|
|
|
|
|
|
print_feedback "Starting ComfyUI server..."
|
|
|
|
print_feedback "ComfyUI will be available at http://0.0.0.0:3000"
|
2024-07-13 20:19:26 +02:00
|
|
|
|
|
|
|
# Check if CUSTOM_ARGS is set and not empty
|
|
|
|
if [ -n "$CUSTOM_ARGS" ]; then
|
2024-07-27 11:02:51 +02:00
|
|
|
exec /workspace/venv/bin/python main.py --listen --port 3000 $CUSTOM_ARGS 2>&1 | tee -a $LOG_FILE
|
2024-07-13 20:19:26 +02:00
|
|
|
else
|
2024-07-27 11:02:51 +02:00
|
|
|
exec /workspace/venv/bin/python main.py --listen --port 3000 2>&1 | tee -a $LOG_FILE
|
|
|
|
fi
|