From 64836782671a15a17019ceadccd46e3cf6148d5d Mon Sep 17 00:00:00 2001 From: M_Kececi Date: Tue, 17 Feb 2026 12:49:56 +0300 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- deploy/deploy.sh | 97 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 28 deletions(-) diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 1044408..196c92f 100644 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -6,14 +6,75 @@ export CI="true" export npm_config_progress="false" export npm_config_loglevel="warn" export FORCE_COLOR="0" + LOG_FILE="/var/log/bssapp_deploy.log" APP_DIR="/opt/bssapp" LOCK_FILE="/tmp/bssapp_deploy.lock" +pick_sass_embedded_pkg() { + local arch + arch="$(uname -m)" + + case "$arch" in + x86_64|amd64) + if ldd --version 2>&1 | grep -qi musl; then + echo "sass-embedded-linux-musl-x64@1.93.2" + else + echo "sass-embedded-linux-x64@1.93.2" + fi + ;; + aarch64|arm64) + if ldd --version 2>&1 | grep -qi musl; then + echo "sass-embedded-linux-musl-arm64@1.93.2" + else + echo "sass-embedded-linux-arm64@1.93.2" + fi + ;; + armv7l|armhf) + echo "sass-embedded-linux-arm@1.93.2" + ;; + *) + echo "" + ;; + esac +} + +ensure_sass_embedded() { + local platform_pkg check_output + + platform_pkg="$(pick_sass_embedded_pkg)" + if [[ -z "$platform_pkg" ]]; then + echo "Unsupported CPU architecture for sass-embedded: $(uname -m)" + return 1 + fi + + echo "Installing sass-embedded packages: sass-embedded@1.93.2 + $platform_pkg" + npm i --no-save --no-audit --no-fund sass-embedded@1.93.2 "$platform_pkg" + + check_output="$(./node_modules/.bin/sass --embedded --version 2>&1 || true)" + echo "$check_output" + + if echo "$check_output" | grep -qi "unavailable in pure JS mode"; then + echo "sass --embedded is still unavailable." + return 1 + fi +} + +build_api_binary() { + if ! command -v go >/dev/null 2>&1; then + echo "go command not found; cannot build backend binary." + return 1 + fi + + cd "$APP_DIR/svc" + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" -o "$APP_DIR/bssapp" ./main.go + chmod +x "$APP_DIR/bssapp" +} + run_deploy() { exec 9>"$LOCK_FILE" if ! flock -n 9; then - echo "[$(date '+%F %T')] Deploy zaten calisiyor, yeni istek atlandi." + echo "[$(date '+%F %T')] Deploy already running. Skipping new request." return 0 fi @@ -26,37 +87,17 @@ run_deploy() { echo "== GIT SYNC ==" git fetch origin git reset --hard origin/master - git clean -fdx + git clean -fdx -e bssapp -e nerp echo "== BUILD UI ==" - cd ui + cd "$APP_DIR/ui" npm ci --no-audit --no-fund --include=optional - - # Bazı sunucularda npm optional paketleri atlıyor; bu durumda - # sass --embedded çalışamadığı için Quasar build EPIPE ile düşüyor. - if ! ./node_modules/.bin/sass --embedded --version >/dev/null 2>&1; then - echo "sass-embedded binary yok, platform paketi kuruluyor..." - case "$(uname -m)" in - x86_64|amd64) SASS_EMBEDDED_PKG="sass-embedded-linux-x64@1.93.2" ;; - aarch64|arm64) SASS_EMBEDDED_PKG="sass-embedded-linux-arm64@1.93.2" ;; - armv7l|armhf) SASS_EMBEDDED_PKG="sass-embedded-linux-arm@1.93.2" ;; - *) - echo "Desteklenmeyen mimari: $(uname -m). Sass embedded paketi atlandi." - SASS_EMBEDDED_PKG="" - ;; - esac - - if [[ -n "${SASS_EMBEDDED_PKG}" ]]; then - npm i --no-save --no-audit --no-fund "$SASS_EMBEDDED_PKG" - ./node_modules/.bin/sass --embedded --version >/dev/null 2>&1 || { - echo "sass-embedded hala aktif degil." - return 1 - } - fi - fi - + ensure_sass_embedded npm run build + echo "== BUILD API ==" + build_api_binary + echo "== RESTART SERVICE ==" systemctl restart bssapp @@ -68,6 +109,6 @@ if [[ "${1:-}" == "--run" ]]; then exit 0 fi -# Webhook cagirisini tamamen ayir: pipe kapanmalarinda EPIPE olusmasin. +# Fully detach webhook-triggered process to avoid EPIPE from closed request sockets. nohup /bin/bash "$0" --run /dev/null 2>&1 & exit 0