Files
site_aegisone/max_bot/max_bot_deploy.sh
T
angel 72b6879f4b v1.7.0: refactor max_bot to flat structure, add VCF+UserModel+NLP history context, portal pages and proxy fixes
- Refactored max_bot from nested packages to flat module structure
- Q2: Extended BotUser model (patronymic, email, org, address, vcf_raw, contact_hash, phone_verified, email_verified, last_interaction, total_conversations, total_tickets)
- Q2: VCF parser (FN, N, TEL, EMAIL, ORG, ADR), upsert on re-contact, NLP history context (_get_user_history_context -> YandexGPT)
- Q1: Broadcast preview modal with 10s confirmation timer
- Q3: CSS var(--white)->var(--bg-card), var(--text)->var(--text-primary)
- Q4: bot_settings showNotification(), editable max_bot_id
- Q5: Webhook secret passthrough via X-Max-Bot-Api-Secret
- Masking sensitive keys, dialog_cleared handler, migrate via _add_column_if_not_exists()
- Rate limit (asyncio.sleep 0.5 per 10), dead code removed, conv.intent context in contact.py
- Portal pages: bot_consent, bot_kb (edit), bot_settings, bot_test, bot_tickets, portal_settings
- Tests: 21/21 passing, added test_yandex_gpt.py, test_email_sender.py
- Deploy: deploy_full.sh, schema.sql, seed_knowledge_base.sql
2026-05-29 02:30:30 +03:00

65 lines
1.7 KiB
Bash

#!/bin/bash
# AegisOne MAX Bot — Deploy Script
# Usage: bash max_bot_deploy.sh
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="/opt/projects/aegisone-py"
REMOTE_USER="angel"
REMOTE_HOST="81.177.141.34"
echo "=== MAX Bot Deploy ==="
echo "Building and packaging max_bot..."
cd "$SCRIPT_DIR"
# Create tar archive
cd "$PROJECT_DIR"
tar czf /tmp/max_bot_update.tar.gz \
-C "$SCRIPT_DIR/.." max_bot/ \
--exclude max_bot/__pycache__ \
--exclude max_bot/.pytest_cache \
--exclude "max_bot/*.pyc" \
--exclude max_bot/tests
echo "Copying to server..."
scp /tmp/max_bot_update.tar.gz "$REMOTE_USER@$REMOTE_HOST:/tmp/"
ssh "$REMOTE_USER@$REMOTE_HOST" << 'EOF'
set -e
PROJECT="/opt/projects/aegisone-py/max_bot"
BACKUP="/opt/projects/backups/max_bot_$(date +%Y%m%d_%H%M%S)"
echo "Creating backup..."
if [ -d "$PROJECT" ]; then
mkdir -p "/opt/projects/backups"
cp -a "$PROJECT" "$BACKUP"
fi
echo "Extracting update..."
mkdir -p "$PROJECT"
tar xzf /tmp/max_bot_update.tar.gz -C /opt/projects/aegisone-py/
echo "Rebuilding and restarting container..."
cd "$PROJECT"
docker compose down 2>/dev/null || true
docker compose build --no-cache --network host
docker compose up -d
echo "Checking health..."
sleep 5
for i in 1 2 3 4 5; do
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://max.aegisone.ru/health || echo "000")
if [ "$HTTP_CODE" = "200" ]; then
echo "Health check PASSED (HTTP $HTTP_CODE)"
break
fi
echo "Waiting... attempt $i/5"
sleep 3
done
echo "Deploy complete!"
EOF
echo "=== Done ==="