#!/bin/bash

# Kill existing processes
echo "🔄 Dừng các process cũ..."
pkill -f "node server-new.js" || true
pkill -f "npm start" || true

# Clear locks
echo "🧹 Xóa file lock..."
find . -name "*.lock" -delete 2>/dev/null || true
find . -name ".lock" -delete 2>/dev/null || true
rm -rf node_modules/.cache 2>/dev/null || true

# Install dependencies
echo "📦 Cài đặt dependencies..."
npm install --production

# Set environment
export NODE_ENV=production
export PORT=3000

# Start application
echo "🚀 Khởi động ChatBot GPT..."
node server-new.js

