-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop_tool_servers.sh
More file actions
executable file
·89 lines (76 loc) · 2.27 KB
/
stop_tool_servers.sh
File metadata and controls
executable file
·89 lines (76 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_FILE="${SCRIPT_DIR}/.env"
ENV_EXAMPLE="${SCRIPT_DIR}/.env.example"
COMPOSE_FILE="${SCRIPT_DIR}/docker-compose.tools.yml"
GPU_COMPOSE_FILE="${SCRIPT_DIR}/docker-compose.tools.gpu.yml"
SAMSERVER_GPU_COMPOSE_FILE="${SCRIPT_DIR}/docker-compose.tools.samserver.gpu.yml"
if [[ ! -f "$ENV_FILE" ]]; then
cp "$ENV_EXAMPLE" "$ENV_FILE"
fi
cd "$SCRIPT_DIR"
set -a
source "$ENV_FILE"
set +a
: "${TRELLIS2_ENABLE_GPU:=true}"
: "${SAMSERVER_ENABLE_GPU:=true}"
: "${ENABLE_TRELLIS2:=true}"
: "${ASSET_RETRIEVAL_BACKEND:=objaverse}"
: "${ENABLE_PCG:=true}"
: "${ENABLE_SAMSERVER:=false}"
normalized_asset_retrieval_backend() {
printf '%s' "${ASSET_RETRIEVAL_BACKEND}" | tr '[:upper:]' '[:lower:]'
}
retrieval_compose_service_name() {
case "$(normalized_asset_retrieval_backend)" in
objaverse)
printf 'retrieval'
;;
scenesmith)
printf 'scenesmith_retrieval'
;;
*)
echo "Unsupported ASSET_RETRIEVAL_BACKEND: ${ASSET_RETRIEVAL_BACKEND}" >&2
exit 1
;;
esac
}
if docker compose version >/dev/null 2>&1; then
COMPOSE_BIN=(docker compose)
elif command -v docker-compose >/dev/null 2>&1; then
COMPOSE_BIN=(docker-compose)
else
echo "Neither 'docker compose' nor 'docker-compose' is available." >&2
exit 1
fi
COMPOSE_ARGS=(-f "$COMPOSE_FILE")
if [[ "$TRELLIS2_ENABLE_GPU" == "true" ]]; then
COMPOSE_ARGS+=( -f "$GPU_COMPOSE_FILE" )
fi
if [[ "$SAMSERVER_ENABLE_GPU" == "true" ]]; then
COMPOSE_ARGS+=( -f "$SAMSERVER_GPU_COMPOSE_FILE" )
fi
SERVICES=()
if [[ "$ENABLE_TRELLIS2" == "true" ]]; then
SERVICES+=(trellis2)
fi
if [[ "$(normalized_asset_retrieval_backend)" != "disabled" ]]; then
SERVICES+=("$(retrieval_compose_service_name)")
if [[ "$(normalized_asset_retrieval_backend)" == "objaverse" ]]; then
SERVICES+=(postgres)
fi
fi
if [[ "$ENABLE_PCG" == "true" ]]; then
SERVICES+=(pcg)
fi
if [[ "$ENABLE_SAMSERVER" == "true" ]]; then
SERVICES+=(samserver)
fi
if [[ ${#SERVICES[@]} -eq 0 ]]; then
echo "No services enabled. Nothing to stop." >&2
exit 0
fi
"${COMPOSE_BIN[@]}" "${COMPOSE_ARGS[@]}" stop "${SERVICES[@]}" || true
"${COMPOSE_BIN[@]}" "${COMPOSE_ARGS[@]}" rm -f "${SERVICES[@]}" || true
echo "Stopped services: ${SERVICES[*]}"