| name | deployment-and-ops |
| description | Deploy and operate the vehicle insurance data analysis platform. Use when user asks about local development setup, production deployment, server configuration, build process, service management, or troubleshooting deployment issues. Focuses on the project's actual simple deployment model using start_server.sh, not complex enterprise setups. |
| allowed-tools | Read, Bash, Grep, Glob |
Deployment and Operations Guide
You are assisting with deploying and operating the vehicle insurance data analysis platform. This project uses a simple deployment model suitable for internal teams and small-scale production.
When to Use This Skill
Activate this skill when the user needs help with:
- Setting up local development environment
- Running the application (
start_server.sh)
- Building frontend for production
- Deploying to a server
- Managing services (starting/stopping)
- Troubleshooting deployment issues
- Viewing logs and monitoring
Project Deployment Model
Current Approach: Simple, single-server deployment
- NOT using: Docker, Kubernetes, complex CI/CD
- NOT using: Gunicorn/uWSGI in production yet
- Currently using: Direct Python execution via
start_server.sh
This is appropriate for:
- Internal business tools
- Team size: < 50 users
- Data refreshed daily (not real-time)
Quick Start (Local Development)
Prerequisites Check
Guide the user to verify:
python3 --version
node -v
pwd
Option 1: One-Command Start (Recommended)
./start_server.sh
What this script does:
- Checks Python environment (python3 or python)
- Auto-installs dependencies if missing (Flask, Pandas, etc.)
- Starts Flask backend on port 5000
- Serves static HTML from
/static/index.html
Option 2: Manual Start (for development)
cd backend
python3 api_server.py
cd frontend
npm install
npm run dev
Environment Setup Details
Python Environment
Install dependencies:
pip3 install -r requirements.txt
Optional: Use virtual environment:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Node.js Environment (Frontend Development Only)
Only needed if user wants to modify Vue components:
cd frontend
npm install
npm run dev
npm run build
npm run preview
npm run lint
Production Build
Step 1: Build Frontend
cd frontend
npm run build
Build artifacts: frontend/dist/
index.html - Entry point
assets/ - Bundled JS/CSS with content hashes
Step 2: Deploy to Server
Simple deployment (current method):
scp -r /path/to/签单日报dayreport user@server:/opt/dayreport/
ssh user@server
cd /opt/dayreport
pip3 install -r requirements.txt
./start_server.sh
nohup ./start_server.sh > app.log 2>&1 &
Step 3: Access Application
# If using start_server.sh (default):
http://server-ip:5000/static/index.html
# If using frontend dev server:
http://server-ip:5173
Service Management
Check if Services Running
lsof -i :5000
ps aux | grep api_server
lsof -i :5173
Start/Stop Services
pkill -f api_server
pkill -f vite
cd backend && python3 api_server.py &
cd frontend && npm run dev &
Background Execution
nohup python3 backend/api_server.py > backend.log 2>&1 &
echo $!
kill <PID>
Log Management
Backend Logs
Location: backend/backend.log
tail -f backend/backend.log
tail -n 50 backend/backend.log
grep -i "error" backend/backend.log
tail -f backend/backend.log | while read line; do echo "$(date): $line"; done
Frontend Logs
Browser console: Open DevTools (F12) → Console tab
Build logs: Terminal output during npm run build
Common Deployment Issues
Issue 1: Port Already in Use
Symptom:
OSError: [Errno 48] Address already in use
Solution:
lsof -i :5000
kill -9 <PID>
Issue 2: Dependencies Not Found
Symptom:
ModuleNotFoundError: No module named 'flask'
Solution:
which python3
python3 -m pip list
pip3 install -r requirements.txt
python3 -c "import flask; print(flask.__version__)"
Issue 3: Permission Denied on start_server.sh
Symptom:
-bash: ./start_server.sh: Permission denied
Solution:
chmod +x start_server.sh
./start_server.sh
Issue 4: CSV Files Not Found
Symptom:
FileNotFoundError: 车险清单_2025年10-11月_合并.csv not found
Solution:
ls -la *.csv
ls -la data/
Issue 5: Frontend Build Fails
Symptom:
npm ERR! code ENOENT
Solution:
rm -rf node_modules package-lock.json
npm install
df -h
NODE_OPTIONS=--max-old-space-size=4096 npm run build
Performance Monitoring
Check Resource Usage
top -o CPU
ps aux | grep python3 | grep api_server
df -h
du -sh /path/to/签单日报dayreport/*
API Performance
time curl http://localhost:5000/api/latest-date
for i in {1..10}; do
time curl -s http://localhost:5000/api/kpi?period=day > /dev/null
done
Data Backup
Important files to backup:
车险清单_2025年10-11月_合并.csv
业务员机构团队归属.json
data/*.xlsx
tar -czf backup-$(date +%Y%m%d).tar.gz \
车险清单_2025年10-11月_合并.csv \
业务员机构团队归属.json \
data/
tar -xzf backup-20250108.tar.gz
Advanced Deployment (Future)
Note: These are NOT currently implemented but can be added later:
Option A: Nginx Reverse Proxy
# /etc/nginx/sites-available/dayreport
server {
listen 80;
server_name your-domain.com;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
}
}
Option B: Systemd Service
[Unit]
Description=Dayreport API Service
[Service]
Type=simple
WorkingDirectory=/opt/dayreport
ExecStart=/usr/bin/python3 backend/api_server.py
Restart=always
[Install]
WantedBy=multi-user.target
Enable:
sudo systemctl daemon-reload
sudo systemctl enable dayreport
sudo systemctl start dayreport
For detailed advanced deployment, refer to ADVANCED_DEPLOYMENT.md.
Environment Variables (Optional)
Create .env file (if needed for configuration):
FLASK_ENV=production
FLASK_DEBUG=False
DATA_DIR=/opt/dayreport/data
PORT=5000
Load in Python:
import os
from dotenv import load_dotenv
load_dotenv()
PORT = int(os.getenv('PORT', 5000))
Deployment Checklist
Before deploying to production:
Quick Reference
Essential Commands
./start_server.sh
pkill -f api_server
tail -f backend/backend.log
cd frontend && npm run build
lsof -i :5000
ps aux | grep api_server
File Locations
项目/
├── start_server.sh # Main startup script
├── requirements.txt # Python dependencies
├── backend/
│ ├── api_server.py # Flask app (runs on :5000)
│ ├── data_processor.py # Pandas logic
│ └── backend.log # Runtime logs
├── frontend/
│ ├── package.json # Node dependencies
│ └── dist/ # Built artifacts (after npm run build)
├── data/ # Excel source files
└── *.csv # Processed CSV data
Summary
This skill covers the actual deployment model used by this project:
- Simple startup via
start_server.sh
- Direct Python execution (no container orchestration)
- Suitable for internal tools and small teams
Key principle: Start simple, scale when needed. The current deployment is appropriate for the project's scope.
For enterprise-grade deployment patterns (Docker, K8s, load balancing), refer to advanced guides only if project requirements change.