фикс запуска ad-db ad-db-import
This commit is contained in:
+84
-3
@@ -31,6 +31,68 @@ log() {
|
||||
printf '[start-server] %s\n' "$*"
|
||||
}
|
||||
|
||||
print_service_logs() {
|
||||
local service="$1"
|
||||
printf '\n[%s logs]\n' "$service" >&2
|
||||
docker compose logs --tail=120 "$service" >&2 || true
|
||||
printf '\n' >&2
|
||||
}
|
||||
|
||||
wait_for_healthy() {
|
||||
local container_name="$1"
|
||||
local timeout_seconds="${2:-180}"
|
||||
local start_ts now status
|
||||
|
||||
start_ts="$(date +%s)"
|
||||
|
||||
while :; do
|
||||
status="$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "$container_name" 2>/dev/null || true)"
|
||||
|
||||
case "$status" in
|
||||
healthy|running)
|
||||
return 0
|
||||
;;
|
||||
unhealthy|exited|dead)
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
now="$(date +%s)"
|
||||
if (( now - start_ts >= timeout_seconds )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
done
|
||||
}
|
||||
|
||||
run_one_shot_service() {
|
||||
local service="$1"
|
||||
local container_name="$2"
|
||||
|
||||
if [[ -n "$BUILD_FLAG" ]]; then
|
||||
if ! docker compose up --build --no-deps "$service"; then
|
||||
print_service_logs "$service"
|
||||
printf '%s failed during startup\n' "$service" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
if ! docker compose up --no-deps "$service"; then
|
||||
print_service_logs "$service"
|
||||
printf '%s failed during startup\n' "$service" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local exit_code
|
||||
exit_code="$(docker inspect -f '{{.State.ExitCode}}' "$container_name" 2>/dev/null || printf '1')"
|
||||
if [[ "$exit_code" != "0" ]]; then
|
||||
print_service_logs "$service"
|
||||
printf '%s failed with exit code %s\n' "$service" "$exit_code" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
require_docker() {
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
printf 'docker is not installed or not in PATH\n' >&2
|
||||
@@ -80,11 +142,30 @@ require_docker
|
||||
log "applying module configuration"
|
||||
bash "$ROOT_DIR/setup-modules.sh"
|
||||
|
||||
log "starting docker services"
|
||||
log "starting database"
|
||||
if [[ -n "$BUILD_FLAG" ]]; then
|
||||
docker compose up -d --build
|
||||
docker compose up -d --build ac-database
|
||||
else
|
||||
docker compose up -d
|
||||
docker compose up -d ac-database
|
||||
fi
|
||||
|
||||
if ! wait_for_healthy "ac-database" 180; then
|
||||
print_service_logs "ac-database"
|
||||
printf 'ac-database did not become healthy\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "running database import"
|
||||
run_one_shot_service "ac-db-import" "ac-db-import"
|
||||
|
||||
log "initializing client data"
|
||||
run_one_shot_service "ac-client-data-init" "ac-client-data-init"
|
||||
|
||||
log "starting authserver and worldserver"
|
||||
if [[ -n "$BUILD_FLAG" ]]; then
|
||||
docker compose up -d --build ac-authserver ac-worldserver
|
||||
else
|
||||
docker compose up -d ac-authserver ac-worldserver
|
||||
fi
|
||||
|
||||
log "synchronizing realmlist"
|
||||
|
||||
Reference in New Issue
Block a user