try to add comfy

This commit is contained in:
Mikan
2026-10-06 08:20:50 +04:00
parent dcf77dff50
commit a3c083dad3
4 changed files with 327 additions and 96 deletions

View File

@@ -4,135 +4,244 @@ set -eu
PROJECT_DIR="/project"
get_host_project_dir() {
docker inspect gpu-node-ssh \
--format '{{range .Mounts}}{{if eq .Destination "/project"}}{{.Source}}{{end}}{{end}}'
}
show_status() {
docker ps \
--filter "name=gpu-node-" \
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
}
start_llama() {
MODEL="${1:-model.gguf}"
shift || true
cd "$PROJECT_DIR"
HOST_PROJECT_DIR="$(get_host_project_dir)"
if [ -z "$HOST_PROJECT_DIR" ]; then
echo "ERROR: cannot determine host project directory"
exit 1
fi
EXTRA_ARGS="$*"
echo "Starting llama..."
echo "Model: $MODEL"
echo "Models: $HOST_PROJECT_DIR/gpu/llama_models"
if [ -n "$EXTRA_ARGS" ]; then
echo "Extra args: $EXTRA_ARGS"
fi
LLAMA_MODELS_HOST="$HOST_PROJECT_DIR/gpu/llama_models" \
LLAMA_MODEL="$MODEL" \
LLAMA_EXTRA_ARGS="$EXTRA_ARGS" \
docker compose \
--profile llama \
up -d \
--force-recreate \
llama
echo
docker ps \
--filter "name=gpu-node-llama" \
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
}
start_comfy() {
cd "$PROJECT_DIR"
HOST_PROJECT_DIR="$(get_host_project_dir)"
if [ -z "$HOST_PROJECT_DIR" ]; then
echo "ERROR: cannot determine host project directory"
exit 1
fi
EXTRA_ARGS="$*"
echo "Starting ComfyUI..."
echo "Directory: $HOST_PROJECT_DIR/gpu/comfy"
if [ -n "$EXTRA_ARGS" ]; then
echo "Extra args: $EXTRA_ARGS"
fi
COMFY_BASE_HOST="$HOST_PROJECT_DIR/gpu/comfy" \
COMFY_RUN_HOST="$HOST_PROJECT_DIR/gpu/comfy/run" \
COMFY_EXTRA_ARGS="$EXTRA_ARGS" \
docker compose \
--profile comfy \
up -d \
--force-recreate \
comfyui
echo
docker ps \
--filter "name=gpu-node-comfyui" \
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
}
stop_service() {
SERVICE="$1"
case "$SERVICE" in
llama)
docker stop gpu-node-llama 2>/dev/null || true
;;
comfy)
docker stop gpu-node-comfyui 2>/dev/null || true
;;
tailscale)
docker stop gpu-node-tailscale 2>/dev/null || true
;;
ssh)
docker stop gpu-node-ssh 2>/dev/null || true
;;
*)
echo "Unknown service: $SERVICE"
exit 1
;;
esac
}
restart_service() {
SERVICE="$1"
case "$SERVICE" in
llama)
docker restart gpu-node-llama
;;
comfy)
docker restart gpu-node-comfyui
;;
tailscale)
docker restart gpu-node-tailscale
;;
ssh)
docker restart gpu-node-ssh
;;
*)
echo "Unknown service: $SERVICE"
exit 1
;;
esac
}
logs_service() {
SERVICE="$1"
case "$SERVICE" in
llama)
docker logs -f gpu-node-llama
;;
comfy)
docker logs -f gpu-node-comfyui
;;
tailscale)
docker logs -f gpu-node-tailscale
;;
ssh)
docker logs -f gpu-node-ssh
;;
*)
echo "Unknown service: $SERVICE"
exit 1
;;
esac
}
case "${1:-}" in
status)
docker ps \
--filter "name=gpu-node-" \
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
show_status
;;
start)
case "${2:-}" in
llama)
cd "$PROJECT_DIR"
HOST_PROJECT_DIR="$(get_host_project_dir)"
if [ -z "$HOST_PROJECT_DIR" ]; then
echo "ERROR: cannot determine host project directory"
exit 1
fi
echo "Starting llama..."
echo "Models: $HOST_PROJECT_DIR/gpu/llama_models"
LLAMA_MODELS_HOST="$HOST_PROJECT_DIR/gpu/llama_models" \
docker compose --profile llama up -d llama
echo
docker ps \
--filter "name=gpu-node-llama" \
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
shift 2
start_llama "$@"
;;
comfy)
cd "$PROJECT_DIR"
HOST_PROJECT_DIR="$(get_host_project_dir)"
if [ -z "$HOST_PROJECT_DIR" ]; then
echo "ERROR: cannot determine host project directory"
exit 1
fi
echo "Starting ComfyUI..."
echo "Models: $HOST_PROJECT_DIR/gpu/comfy_models"
COMFY_MODELS_HOST="$HOST_PROJECT_DIR/gpu/comfy_models" \
docker compose --profile comfy up -d comfyui
echo
docker ps \
--filter "name=gpu-node-comfyui" \
--format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
shift 2
start_comfy "$@"
;;
*)
echo "Usage: gpuctl start {llama|comfy}"
echo "Usage:"
echo " gpuctl start llama [model.gguf] [extra args...]"
echo " gpuctl start comfy [extra args...]"
exit 1
;;
esac
;;
stop)
case "${2:-}" in
if [ -z "${2:-}" ]; then
echo "Usage: gpuctl stop <service>"
exit 1
fi
llama)
docker stop gpu-node-llama
;;
comfy)
docker stop gpu-node-comfyui
;;
*)
echo "Usage: gpuctl stop {llama|comfy}"
exit 1
;;
esac
stop_service "$2"
;;
restart)
case "${2:-}" in
if [ -z "${2:-}" ]; then
echo "Usage: gpuctl restart <service>"
exit 1
fi
llama)
docker restart gpu-node-llama
;;
comfy)
docker restart gpu-node-comfyui
;;
*)
echo "Usage: gpuctl restart {llama|comfy}"
exit 1
;;
esac
restart_service "$2"
;;
logs)
case "${2:-}" in
if [ -z "${2:-}" ]; then
echo "Usage: gpuctl logs <service>"
exit 1
fi
llama)
docker logs --tail 100 gpu-node-llama
;;
comfy)
docker logs --tail 100 gpu-node-comfyui
;;
*)
echo "Usage: gpuctl logs {llama|comfy}"
exit 1
;;
esac
logs_service "$2"
;;
*)
echo "GPU node controller"
echo
echo "Usage:"
echo " gpuctl status"
echo " gpuctl start {llama|comfy}"
echo " gpuctl stop {llama|comfy}"
echo " gpuctl restart {llama|comfy}"
echo " gpuctl logs {llama|comfy}"
echo " gpuctl start llama [model.gguf] [extra args...]"
echo " gpuctl start comfy [extra args...]"
echo " gpuctl stop <service>"
echo " gpuctl restart <service>"
echo " gpuctl logs <service>"
exit 1
;;
esac
esac