Complete deployment: Nginx + Supervisor + Auto-deploy
This commit is contained in:
parent
fef365d00d
commit
e036139490
|
|
@ -0,0 +1,232 @@
|
|||
# 🚀 Deployment Guide - Hosting Platform
|
||||
|
||||
## 📊 Server Information
|
||||
|
||||
**Server IP**: `176.96.129.77`
|
||||
**OS**: Ubuntu 24.04 LTS
|
||||
**RAM**: 4GB
|
||||
**CPU**: 4 cores
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Deployed Services
|
||||
|
||||
### ✅ Core Services
|
||||
|
||||
| Service | Port | URL | Status |
|
||||
|---------|------|-----|--------|
|
||||
| **Frontend (React)** | 3001 | http://176.96.129.77 | ✅ Running |
|
||||
| **Backend API (Flask)** | 5000 | http://176.96.129.77/api | ✅ Running |
|
||||
| **Gitea** | 3000 | http://176.96.129.77:3000 | ✅ Running |
|
||||
| **PostgreSQL** | 5432 | localhost | ✅ Running |
|
||||
| **Redis** | 6379 | localhost | ✅ Running |
|
||||
| **Nginx** | 80 | http://176.96.129.77 | ✅ Running |
|
||||
|
||||
### 🔐 Credentials
|
||||
|
||||
**Gitea Admin**:
|
||||
- Username: `hostadmin`
|
||||
- Password: `HostAdmin2024!`
|
||||
- Repository: http://176.96.129.77:3000/hostadmin/hosting-platform
|
||||
|
||||
**PostgreSQL**:
|
||||
- User: `hosting_user`
|
||||
- Password: `HostingDB2024!`
|
||||
- Database: `hosting_db`
|
||||
|
||||
**Redis**:
|
||||
- No password (localhost only)
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture
|
||||
|
||||
```
|
||||
Internet
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────┐
|
||||
│ Nginx Reverse Proxy (Port 80) │
|
||||
│ - Frontend: / │
|
||||
│ - Backend API: /api │
|
||||
│ - Webhook: /webhook │
|
||||
└─────────────────────────────────────┘
|
||||
│
|
||||
├──────────────┬──────────────┐
|
||||
▼ ▼ ▼
|
||||
┌─────────┐ ┌──────────┐ ┌──────────┐
|
||||
│Frontend │ │ Backend │ │ Gitea │
|
||||
│ :3001 │ │ :5000 │ │ :3000 │
|
||||
└─────────┘ └──────────┘ └──────────┘
|
||||
│
|
||||
┌─────────┴─────────┐
|
||||
▼ ▼
|
||||
┌──────────┐ ┌─────────┐
|
||||
│PostgreSQL│ │ Redis │
|
||||
│ :5432 │ │ :6379 │
|
||||
└──────────┘ └─────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 Directory Structure
|
||||
|
||||
```
|
||||
/opt/hosting-platform/
|
||||
├── backend/
|
||||
│ ├── app/
|
||||
│ │ ├── __init__.py
|
||||
│ │ ├── main.py
|
||||
│ │ ├── config.py
|
||||
│ │ ├── models/
|
||||
│ │ │ ├── __init__.py
|
||||
│ │ │ └── domain.py
|
||||
│ │ ├── services/
|
||||
│ │ │ ├── __init__.py
|
||||
│ │ │ └── cloudflare_service.py
|
||||
│ │ └── api/
|
||||
│ ├── venv/
|
||||
│ └── requirements.txt
|
||||
├── frontend/
|
||||
│ ├── src/
|
||||
│ │ ├── App.jsx
|
||||
│ │ ├── main.jsx
|
||||
│ │ ├── pages/
|
||||
│ │ │ ├── DomainSetup.jsx
|
||||
│ │ │ └── DomainList.jsx
|
||||
│ │ └── services/
|
||||
│ │ └── api.js
|
||||
│ ├── package.json
|
||||
│ └── vite.config.js
|
||||
└── deploy.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Auto-Deploy Workflow
|
||||
|
||||
1. **Developer pushes code** to `main` branch
|
||||
2. **Gitea webhook** triggers → `POST http://176.96.129.77:5000/webhook/deploy`
|
||||
3. **Backend receives webhook** → Executes `/opt/hosting-platform/deploy.sh`
|
||||
4. **Deploy script**:
|
||||
- Pulls latest code from Git
|
||||
- Installs dependencies
|
||||
- Restarts services via Supervisor
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Management Commands
|
||||
|
||||
### Supervisor (Process Management)
|
||||
|
||||
```bash
|
||||
# Check status
|
||||
supervisorctl status
|
||||
|
||||
# Restart services
|
||||
supervisorctl restart hosting-backend
|
||||
supervisorctl restart hosting-frontend
|
||||
|
||||
# View logs
|
||||
tail -f /var/log/hosting-backend.log
|
||||
tail -f /var/log/hosting-frontend.log
|
||||
|
||||
# Stop/Start
|
||||
supervisorctl stop hosting-backend
|
||||
supervisorctl start hosting-backend
|
||||
```
|
||||
|
||||
### Nginx
|
||||
|
||||
```bash
|
||||
# Test configuration
|
||||
nginx -t
|
||||
|
||||
# Reload
|
||||
systemctl reload nginx
|
||||
|
||||
# Restart
|
||||
systemctl restart nginx
|
||||
|
||||
# View logs
|
||||
tail -f /var/log/nginx/access.log
|
||||
tail -f /var/log/nginx/error.log
|
||||
```
|
||||
|
||||
### Database
|
||||
|
||||
```bash
|
||||
# Connect to PostgreSQL
|
||||
psql -U hosting_user -d hosting_db
|
||||
|
||||
# Connect to Redis
|
||||
redis-cli
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🧪 Testing
|
||||
|
||||
### Health Check
|
||||
```bash
|
||||
curl http://176.96.129.77/health
|
||||
```
|
||||
|
||||
### API Test
|
||||
```bash
|
||||
curl http://176.96.129.77/api/domains
|
||||
```
|
||||
|
||||
### Frontend
|
||||
Open browser: http://176.96.129.77
|
||||
|
||||
---
|
||||
|
||||
## 📝 Next Steps
|
||||
|
||||
1. ✅ **Add SSL Certificate** (Let's Encrypt)
|
||||
2. ✅ **Configure Domain Name**
|
||||
3. ✅ **Set up Monitoring** (Prometheus/Grafana)
|
||||
4. ✅ **Add Backup System**
|
||||
5. ✅ **Implement Authentication**
|
||||
|
||||
---
|
||||
|
||||
## 🆘 Troubleshooting
|
||||
|
||||
### Backend not starting
|
||||
```bash
|
||||
# Check logs
|
||||
tail -f /var/log/hosting-backend.log
|
||||
|
||||
# Check if port is in use
|
||||
lsof -i :5000
|
||||
|
||||
# Restart
|
||||
supervisorctl restart hosting-backend
|
||||
```
|
||||
|
||||
### Frontend not loading
|
||||
```bash
|
||||
# Check logs
|
||||
tail -f /var/log/hosting-frontend.log
|
||||
|
||||
# Restart
|
||||
supervisorctl restart hosting-frontend
|
||||
```
|
||||
|
||||
### Database connection issues
|
||||
```bash
|
||||
# Check PostgreSQL status
|
||||
systemctl status postgresql
|
||||
|
||||
# Check connections
|
||||
psql -U hosting_user -d hosting_db -c "SELECT * FROM pg_stat_activity;"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Deployment Date**: 2026-01-10
|
||||
**Version**: 1.0.0
|
||||
**Deployed By**: Hosting Platform Team
|
||||
|
||||
Loading…
Reference in New Issue