File size: 2,092 Bytes
4cfc8a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash

# πŸ”„ YouTube Metadata Extractor - Update Script
# This script updates the project on a remote server

echo "πŸ”„ Updating YouTube Metadata Extractor..."

# Configuration
PROJECT_DIR="$HOME/YouTube"

# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color

# Function to print colored output
print_status() {
    echo -e "${GREEN}βœ… $1${NC}"
}

print_warning() {
    echo -e "${YELLOW}⚠️ $1${NC}"
}

print_error() {
    echo -e "${RED}❌ $1${NC}"
}

# Check if project directory exists
if [ ! -d "$PROJECT_DIR" ]; then
    print_error "Project directory not found: $PROJECT_DIR"
    print_error "Please run deploy.sh first to set up the project"
    exit 1
fi

cd "$PROJECT_DIR"

# Stop services
print_status "Stopping services..."
sudo systemctl stop youtube-api.service youtube-bot.service

# Pull latest changes
print_status "Pulling latest changes from repository..."
git pull origin main

# Activate virtual environment and update dependencies
print_status "Updating Python dependencies..."
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
pip install -r telegram_requirements.txt

# Start services
print_status "Starting services..."
sudo systemctl start youtube-api.service youtube-bot.service

# Check service status
print_status "Checking service status..."
sleep 5

if systemctl is-active --quiet youtube-api.service; then
    print_status "YouTube API Server is running"
else
    print_error "YouTube API Server failed to start"
    sudo systemctl status youtube-api.service
fi

if systemctl is-active --quiet youtube-bot.service; then
    print_status "YouTube Telegram Bot is running"
else
    print_error "YouTube Telegram Bot failed to start"
    sudo systemctl status youtube-bot.service
fi

print_status "Update completed!"
echo ""
echo "πŸ“‹ Useful commands:"
echo "- Check logs: sudo journalctl -f -u youtube-api -u youtube-bot"
echo "- Service status: sudo systemctl status youtube-api youtube-bot"
echo "- Restart services: sudo systemctl restart youtube-api youtube-bot"