Potato को सर्वर पर तैनात करना
Docker, nginx, SSL और AWS, GCP तथा Azure जैसे क्लाउड प्लेटफ़ॉर्म पर Potato को प्रोडक्शन में तैनात कीजिए। systemd सेवा का कॉन्फ़िगरेशन और स्केलिंग के सुझाव भी शामिल हैं।
यह मार्गदर्शिका Potato को प्रोडक्शन में चलाने की बात करती है: सर्वर का सेटअप, Docker, बड़े क्लाउड प्लेटफ़ॉर्म, और वह सुरक्षा कॉन्फ़िगरेशन जो इंटरनेट पर कुछ भी खोलने से पहले चाहिए। GitHub पर मौजूद तैनाती का दस्तावेज़ इनमें से कुछ विषयों में और गहराई तक जाता है।
तैनाती के विकल्प
| तरीक़ा | किसके लिए सबसे ठीक | कठिनाई |
|---|---|---|
| Local | विकास, परीक्षण | कम |
| Docker | दोहराई जा सकने वाली तैनाती | मध्यम |
| Cloud VM | पूरा नियंत्रण, अपने हिसाब का सेटअप | मध्यम |
| Docker Compose | कई कंटेनर वाले सेटअप | मध्यम |
| Kubernetes | बड़े पैमाने की तैनाती | ज़्यादा |
बुनियादी सर्वर तैनाती
पहले से क्या चाहिए
# Ubuntu/Debian server
sudo apt update
sudo apt install python3.9 python3-pip nginx certbot python3-certbot-nginx
# Create directory structure
mkdir -p /opt/potato/projects
cd /opt/potatoइंस्टॉलेशन
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install Potato
pip install potato-annotation
# Verify installation
potato --versionGunicorn के साथ चलाना
# Install production server
pip install gunicorn
# Run with gunicorn
gunicorn -w 4 -b 127.0.0.1:8000 \
--chdir /opt/potato/projects/my_project \
"potato.server:create_app(config_path='config.yaml')"Systemd सेवा
/etc/systemd/system/potato.service बनाइए:
[Unit]
Description=Potato Annotation Server
After=network.target
[Service]
Type=simple
User=potato
Group=potato
WorkingDirectory=/opt/potato/projects/my_project
Environment="PATH=/opt/potato/venv/bin"
ExecStart=/opt/potato/venv/bin/gunicorn -w 4 -b 127.0.0.1:8000 \
"potato.server:create_app(config_path='config.yaml')"
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetचालू कीजिए और शुरू कीजिए:
sudo systemctl enable potato
sudo systemctl start potato
sudo systemctl status potatoNginx का कॉन्फ़िगरेशन
बुनियादी reverse proxy
/etc/nginx/sites-available/potato बनाइए:
server {
listen 80;
server_name annotation.example.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support (if needed)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Static files
location /static/ {
alias /opt/potato/projects/my_project/static/;
expires 30d;
add_header Cache-Control "public, no-transform";
}
# Upload size limit
client_max_body_size 100M;
}साइट चालू कीजिए:
sudo ln -s /etc/nginx/sites-available/potato /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxLet's Encrypt से SSL
# Get SSL certificate
sudo certbot --nginx -d annotation.example.com
# Auto-renewal
sudo systemctl enable certbot.timerDocker से तैनाती
Dockerfile
FROM python:3.9-slim
WORKDIR /app
# Install dependencies
RUN pip install potato-annotation gunicorn
# Copy project files
COPY config.yaml .
COPY data/ ./data/
# Create directories
RUN mkdir -p annotations logs
# Expose port
EXPOSE 8000
# Run server
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", \
"potato.server:create_app(config_path='config.yaml')"]बनाना और चलाना
# Build image
docker build -t potato-annotation .
# Run container
docker run -d \
--name potato \
-p 8000:8000 \
-v $(pwd)/annotations:/app/annotations \
-v $(pwd)/logs:/app/logs \
potato-annotationDocker Compose
# docker-compose.yml
version: '3.8'
services:
potato:
build: .
ports:
- "8000:8000"
volumes:
- ./data:/app/data:ro
- ./annotations:/app/annotations
- ./logs:/app/logs
environment:
- POTATO_ENV=production
restart: unless-stopped
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./ssl:/etc/nginx/ssl:ro
depends_on:
- potato
restart: unless-stoppedक्लाउड प्लेटफ़ॉर्म पर तैनाती
AWS EC2
# Launch EC2 instance (Ubuntu 22.04)
# Configure security group: ports 22, 80, 443
# SSH to instance
ssh -i your-key.pem ubuntu@your-instance-ip
# Follow basic server deployment steps above
# For persistent storage, attach EBS volume
sudo mount /dev/xvdf /opt/potato/dataGoogle Cloud Platform
# Create VM instance
gcloud compute instances create potato-server \
--zone=us-central1-a \
--machine-type=e2-medium \
--image-family=ubuntu-2204-lts \
--image-project=ubuntu-os-cloud
# Configure firewall
gcloud compute firewall-rules create allow-http \
--allow tcp:80,tcp:443DigitalOcean
# Create droplet via CLI
doctl compute droplet create potato-server \
--size s-2vcpu-4gb \
--image ubuntu-22-04-x64 \
--region nyc1प्रोडक्शन के लिए कॉन्फ़िगरेशन
प्रोडक्शन कॉन्फ़िग
# config.yaml
annotation_task_name: "Production Annotation Task"
# Note: Server settings (host, port, workers) are CLI flags:
# potato -p 8000 --host 0.0.0.0 config.yaml
# Or use gunicorn for production with multiple workers
# Logging
logging:
level: INFO
file: logs/potato.log
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
rotation:
max_size: 10MB
backup_count: 5
# Data
data_files:
- items.jsonl
item_properties:
id_key: id
text_key: text
# Output
output_annotation_dir: annotations/
export_annotation_format: jsonlEnvironment variable
# /opt/potato/.env
POTATO_SECRET_KEY=your-secure-random-key-here
POTATO_ENV=production
OPENAI_API_KEY=sk-... # If using AI featuressystemd में लोड कीजिए:
[Service]
EnvironmentFile=/opt/potato/.envसुरक्षा के लिए बेहतर तरीक़े
अगर आप परियोजना को ओपन सोर्स कर रहे हैं या आम लोगों से डेटा जुटा रहे हैं, तो open-sourcing की मार्गदर्शिका भी पढ़ें, जिसमें निजता और लाइसेंसिंग के वे पहलू हैं जो यह खंड नहीं छूता।
प्रमाणीकरण
user_config:
auth_type: password
# Strong password requirements
password_policy:
min_length: 12
require_uppercase: true
require_number: true
# Session security
session:
secure_cookie: true
http_only: true
same_site: strictHTTPS का कॉन्फ़िगरेशन
server {
listen 443 ssl http2;
server_name annotation.example.com;
ssl_certificate /etc/letsencrypt/live/annotation.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/annotation.example.com/privkey.pem;
# Modern SSL configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
# Security headers
add_header Strict-Transport-Security "max-age=63072000" always;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
# ... rest of config
}Firewall
# UFW configuration
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw enableनिगरानी
Health check endpoint
# Check server health
curl http://localhost:8000/health
# Expected response
{"status": "healthy", "version": "2.0.0"}लॉग पर नज़र
# View logs
sudo journalctl -u potato -f
# Or check log file
tail -f /opt/potato/logs/potato.logPrometheus के मीट्रिक (वैकल्पिक)
# config.yaml
monitoring:
prometheus:
enabled: true
port: 9090बैकअप की रणनीति
स्वचालित बैकअप
# backup.sh
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR=/opt/potato/backups
# Backup annotations
tar -czf $BACKUP_DIR/annotations_$DATE.tar.gz /opt/potato/projects/*/annotations/
# Backup configs
tar -czf $BACKUP_DIR/configs_$DATE.tar.gz /opt/potato/projects/*/config.yaml
# Remove old backups (keep 7 days)
find $BACKUP_DIR -mtime +7 -delete
# Optional: sync to cloud storage
# aws s3 sync $BACKUP_DIR s3://your-bucket/potato-backups/crontab में जोड़िए:
# Run daily at 2am
0 2 * * * /opt/potato/backup.shस्केलिंग
कई worker
# Increase gunicorn workers based on CPU cores
gunicorn -w $((2 * $(nproc) + 1)) -b 0.0.0.0:8000 ...Load balancing
upstream potato_servers {
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
server {
location / {
proxy_pass http://potato_servers;
}
}दिक़्क़तें सुलझाना
आम समस्याएँ
पोर्ट पहले से इस्तेमाल में है:
sudo lsof -i :8000
sudo kill -9 <PID>अनुमति नहीं मिली:
sudo chown -R potato:potato /opt/potatoमेमोरी ख़त्म:
# Add swap space
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfileऔर मदद के लिए पूरा दस्तावेज़ या GitHub discussions देखें।