mirror of
git://f0xx.org/ac/ac-deploy
synced 2026-07-29 05:59:05 +03:00
cluster0: sync ac-workspace and url-shortener on lab deploy
Add deploy-ac-workspace, deploy-ac-url-shortener, validate-ac-repos; wire into populate app phase and verify_lab_setup. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,6 +27,15 @@ GIT_BRANCH=next
|
|||||||
# git | bundle — bundle uses SHARED_MOUNT/cluster/release/current/
|
# git | bundle — bundle uses SHARED_MOUNT/cluster/release/current/
|
||||||
APP_SOURCE=git
|
APP_SOURCE=git
|
||||||
|
|
||||||
|
# ac/* org (SPEC migration — git server SoT; Gitea browse only, not required for deploy)
|
||||||
|
AC_GIT_BASE=git://f0xx.org/ac
|
||||||
|
AC_WORKSPACE_ORIGIN=git://f0xx.org/ac/ac-workspace
|
||||||
|
AC_WORKSPACE_ROOT=/var/www/ac/workspace
|
||||||
|
AC_GIT_BRANCH=next
|
||||||
|
AC_SUBMODULES_CORE="ac-platform-db ac-platform-php ac-platform-web ac-platform-edge ac-deploy ac-docs ac-scripts ac-ms-url-shortener ac-be-hub ac-ms-identity"
|
||||||
|
URL_SHORTENER_ORIGIN=git://f0xx.org/ac/ac-ms-url-shortener
|
||||||
|
URL_SHORTENER_ROOT=/var/www/url-shortener
|
||||||
|
|
||||||
APP_ROOT=/var/www/localhost/htdocs/apps/app/androidcast_project
|
APP_ROOT=/var/www/localhost/htdocs/apps/app/androidcast_project
|
||||||
APP_BASE_PATH=/app/androidcast_project/crashes
|
APP_BASE_PATH=/app/androidcast_project/crashes
|
||||||
APP_HUB_PATH=/app/androidcast_project
|
APP_HUB_PATH=/app/androidcast_project
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ run_phase_app() {
|
|||||||
wait_for_primary_db
|
wait_for_primary_db
|
||||||
fi
|
fi
|
||||||
run_script "$ROOT/scripts/deploy-app.sh"
|
run_script "$ROOT/scripts/deploy-app.sh"
|
||||||
|
run_script "$ROOT/scripts/deploy-ac-workspace.sh"
|
||||||
|
run_script "$ROOT/scripts/deploy-ac-url-shortener.sh"
|
||||||
run_script "$ROOT/scripts/configure-nginx.sh"
|
run_script "$ROOT/scripts/configure-nginx.sh"
|
||||||
rc-service php-fpm83 restart 2>/dev/null || true
|
rc-service php-fpm83 restart 2>/dev/null || true
|
||||||
rc-service nginx reload 2>/dev/null || rc-service nginx restart 2>/dev/null || true
|
rc-service nginx reload 2>/dev/null || rc-service nginx restart 2>/dev/null || true
|
||||||
|
|||||||
28
sim/cluster0/scripts/deploy-ac-url-shortener.sh
Executable file
28
sim/cluster0/scripts/deploy-ac-url-shortener.sh
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Deploy ac-ms-url-shortener (replaces monolith submodule path on lab nodes).
|
||||||
|
set -eu
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "$ROOT/scripts/lib/common.sh"
|
||||||
|
load_cluster_env
|
||||||
|
|
||||||
|
URL_ROOT="${URL_SHORTENER_ROOT:-/var/www/url-shortener}"
|
||||||
|
ORIGIN="${URL_SHORTENER_ORIGIN:-git://f0xx.org/ac/ac-ms-url-shortener}"
|
||||||
|
BRANCH="${AC_GIT_BRANCH:-next}"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$URL_ROOT")"
|
||||||
|
git config --global --add safe.directory "$URL_ROOT" 2>/dev/null || true
|
||||||
|
|
||||||
|
if [ -d "${URL_ROOT}/.git" ]; then
|
||||||
|
log "url-shortener pull ${BRANCH}"
|
||||||
|
git -C "$URL_ROOT" fetch origin
|
||||||
|
git -C "$URL_ROOT" checkout "$BRANCH"
|
||||||
|
git -C "$URL_ROOT" pull --ff-only origin "$BRANCH" || git -C "$URL_ROOT" reset --hard "origin/${BRANCH}"
|
||||||
|
else
|
||||||
|
log "url-shortener clone ${ORIGIN}"
|
||||||
|
rm -rf "$URL_ROOT"
|
||||||
|
git clone --branch "$BRANCH" --depth 1 "$ORIGIN" "$URL_ROOT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown -R nginx:nginx "$URL_ROOT" 2>/dev/null || true
|
||||||
|
log "deploy-ac-url-shortener_ok $(host_short) $(git -C "$URL_ROOT" rev-parse --short HEAD)"
|
||||||
34
sim/cluster0/scripts/deploy-ac-workspace.sh
Executable file
34
sim/cluster0/scripts/deploy-ac-workspace.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Clone/update ac-workspace and core ac/* submodules (lab local disk).
|
||||||
|
set -eu
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "$ROOT/scripts/lib/common.sh"
|
||||||
|
load_cluster_env
|
||||||
|
|
||||||
|
AC_ROOT="${AC_WORKSPACE_ROOT:-/var/www/ac/workspace}"
|
||||||
|
ORIGIN="${AC_WORKSPACE_ORIGIN:-git://f0xx.org/ac/ac-workspace}"
|
||||||
|
BRANCH="${AC_GIT_BRANCH:-next}"
|
||||||
|
SUBS="${AC_SUBMODULES_CORE:-ac-platform-db ac-platform-php ac-platform-web ac-platform-edge ac-deploy ac-docs ac-scripts ac-ms-url-shortener ac-be-hub ac-ms-identity}"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$AC_ROOT")"
|
||||||
|
git config --global --add safe.directory "$AC_ROOT" 2>/dev/null || true
|
||||||
|
|
||||||
|
if [ -d "${AC_ROOT}/.git" ]; then
|
||||||
|
log "ac-workspace pull ${BRANCH} in ${AC_ROOT}"
|
||||||
|
git -C "$AC_ROOT" fetch origin
|
||||||
|
git -C "$AC_ROOT" checkout "$BRANCH"
|
||||||
|
git -C "$AC_ROOT" pull --ff-only origin "$BRANCH" || git -C "$AC_ROOT" reset --hard "origin/${BRANCH}"
|
||||||
|
else
|
||||||
|
log "ac-workspace clone ${ORIGIN} → ${AC_ROOT}"
|
||||||
|
rm -rf "$AC_ROOT"
|
||||||
|
git clone --branch "$BRANCH" --depth 1 "$ORIGIN" "$AC_ROOT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$AC_ROOT"
|
||||||
|
log "submodule init: ${SUBS}"
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
git submodule update --init --depth 1 $SUBS
|
||||||
|
|
||||||
|
chown -R nginx:nginx "$(dirname "$AC_ROOT")" 2>/dev/null || true
|
||||||
|
log "deploy-ac-workspace_ok $(host_short) $(git -C "$AC_ROOT" rev-parse --short HEAD)"
|
||||||
56
sim/cluster0/scripts/validate-ac-repos.sh
Executable file
56
sim/cluster0/scripts/validate-ac-repos.sh
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Validate ac-workspace + legacy runtime on this cluster node.
|
||||||
|
set -eu
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
. "$ROOT/scripts/lib/common.sh"
|
||||||
|
load_cluster_env
|
||||||
|
|
||||||
|
FAIL=0
|
||||||
|
check_dir() {
|
||||||
|
_label="$1"
|
||||||
|
_path="$2"
|
||||||
|
if [ -d "$_path" ]; then
|
||||||
|
log "OK ${_label} ${_path}"
|
||||||
|
else
|
||||||
|
log "FAIL missing ${_label} ${_path}"
|
||||||
|
FAIL=1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_file() {
|
||||||
|
_label="$1"
|
||||||
|
_path="$2"
|
||||||
|
if [ -f "$_path" ]; then
|
||||||
|
log "OK ${_label}"
|
||||||
|
else
|
||||||
|
log "FAIL missing ${_label} ${_path}"
|
||||||
|
FAIL=1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
AC_ROOT="${AC_WORKSPACE_ROOT:-/var/www/ac/workspace}"
|
||||||
|
LEGACY="${APP_ROOT}/android_cast"
|
||||||
|
|
||||||
|
log "validate-ac-repos on $(host_short)"
|
||||||
|
check_dir "ac-workspace" "$AC_ROOT"
|
||||||
|
check_dir "ac-platform-db" "${AC_ROOT}/ac-platform-db/sql/crash_reporter"
|
||||||
|
check_dir "ac-platform-php" "${AC_ROOT}/ac-platform-php/src"
|
||||||
|
check_dir "ac-platform-web" "${AC_ROOT}/ac-platform-web/assets/css"
|
||||||
|
check_dir "legacy-monolith" "$LEGACY"
|
||||||
|
check_file "legacy-backend" "${LEGACY}/examples/crash_reporter/backend/public/index.php"
|
||||||
|
check_dir "url-shortener" "${URL_SHORTENER_ROOT:-/var/www/url-shortener}/public"
|
||||||
|
|
||||||
|
if [ -d "${AC_ROOT}/.git" ]; then
|
||||||
|
log "ac-workspace_sha=$(git -C "$AC_ROOT" rev-parse --short HEAD 2>/dev/null || echo none)"
|
||||||
|
fi
|
||||||
|
if [ -d "${LEGACY}/.git" ]; then
|
||||||
|
log "legacy_sha=$(git -C "$LEGACY" rev-parse --short HEAD 2>/dev/null || echo none)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$FAIL" -eq 0 ]; then
|
||||||
|
log "validate-ac-repos_ok"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
log "validate-ac-repos_FAILED"
|
||||||
|
exit 1
|
||||||
@@ -46,6 +46,10 @@ check_local_node() {
|
|||||||
DIAG="$(curl -sS "http://127.0.0.1${APP_BASE_PATH}/api/diag.php" 2>/dev/null || true)"
|
DIAG="$(curl -sS "http://127.0.0.1${APP_BASE_PATH}/api/diag.php" 2>/dev/null || true)"
|
||||||
echo "$DIAG" | grep -q '"ok":true' || { log "FAIL diag.php"; FAIL=1; }
|
echo "$DIAG" | grep -q '"ok":true' || { log "FAIL diag.php"; FAIL=1; }
|
||||||
|
|
||||||
|
if [ -x "$ROOT/scripts/validate-ac-repos.sh" ]; then
|
||||||
|
sh "$ROOT/scripts/validate-ac-repos.sh" || FAIL=1
|
||||||
|
fi
|
||||||
|
|
||||||
CRASH_N="$(mariadb -u androidcast -p"$(read_cred mariadb_app password)" -h127.0.0.1 -N -e \
|
CRASH_N="$(mariadb -u androidcast -p"$(read_cred mariadb_app password)" -h127.0.0.1 -N -e \
|
||||||
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='androidcast_crashes'" 2>/dev/null || echo 0)"
|
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='androidcast_crashes'" 2>/dev/null || echo 0)"
|
||||||
[ "$CRASH_N" = "$EXPECTED_CRASHES_TABLES" ] || { log "FAIL crashes tables=$CRASH_N want $EXPECTED_CRASHES_TABLES"; FAIL=1; }
|
[ "$CRASH_N" = "$EXPECTED_CRASHES_TABLES" ] || { log "FAIL crashes tables=$CRASH_N want $EXPECTED_CRASHES_TABLES"; FAIL=1; }
|
||||||
|
|||||||
Reference in New Issue
Block a user