Files
bssapp/deploy/deploy.sh
2026-02-17 12:41:37 +03:00

74 lines
2.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
set -euo pipefail
export NODE_OPTIONS="--max_old_space_size=4096"
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"
run_deploy() {
exec 9>"$LOCK_FILE"
if ! flock -n 9; then
echo "[$(date '+%F %T')] Deploy zaten calisiyor, yeni istek atlandi."
return 0
fi
echo "=============================="
echo "[DEPLOY START] $(date '+%F %T')"
echo "=============================="
cd "$APP_DIR"
echo "== GIT SYNC =="
git fetch origin
git reset --hard origin/master
git clean -fdx
echo "== BUILD UI =="
cd 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
npm run build
echo "== RESTART SERVICE =="
systemctl restart bssapp
echo "[DEPLOY FINISHED] $(date '+%F %T')"
}
if [[ "${1:-}" == "--run" ]]; then
run_deploy >>"$LOG_FILE" 2>&1
exit 0
fi
# Webhook cagirisini tamamen ayir: pipe kapanmalarinda EPIPE olusmasin.
nohup /bin/bash "$0" --run </dev/null >/dev/null 2>&1 &
exit 0