File size: 1,316 Bytes
d5ba3a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# Deploy PrimoGreedy Data API to VPS
# Usage: bash vps/deploy.sh

set -e

VPS="ubuntu@100.110.105.118"
REMOTE_DIR="/home/ubuntu/primogreedy"

echo "=== PrimoGreedy VPS Deploy ==="

echo "1. Creating remote directory..."
ssh $VPS "mkdir -p $REMOTE_DIR"

echo "2. Copying files..."
scp vps/api.py vps/requirements.txt vps/.env vps/schema.sql $VPS:$REMOTE_DIR/

echo "3. Installing Python dependencies..."
ssh $VPS "cd $REMOTE_DIR && pip3 install --break-system-packages -r requirements.txt"

echo "4. Creating systemd service..."
ssh $VPS "sudo tee /etc/systemd/system/primogreedy-api.service > /dev/null << 'EOF'
[Unit]
Description=PrimoGreedy Data API
After=network.target

[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/primogreedy
ExecStart=/usr/bin/python3 -m uvicorn api:app --host 0.0.0.0 --port 8080
Restart=always
RestartSec=5
EnvironmentFile=/home/ubuntu/primogreedy/.env

[Install]
WantedBy=multi-user.target
EOF"

echo "5. Starting service..."
ssh $VPS "sudo systemctl daemon-reload && sudo systemctl enable primogreedy-api && sudo systemctl restart primogreedy-api"

echo "6. Checking status..."
sleep 2
ssh $VPS "sudo systemctl status primogreedy-api --no-pager -l" || true

echo ""
echo "=== Deploy complete ==="
echo "Health check: curl http://100.110.105.118:8000/health"