This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# Elasticsearch 日志收集配置(占位)
|
||||
cluster.name: tornado-elevue
|
||||
node.name: node-1
|
||||
network.host: 0.0.0.0
|
||||
http.port: 9200
|
||||
discovery.type: single-node
|
||||
@@ -0,0 +1,22 @@
|
||||
# Logstash 日志管道配置(占位)
|
||||
input {
|
||||
file {
|
||||
path => "/data/apps/logs/app.log"
|
||||
start_position => "beginning"
|
||||
sincedb_path => "/dev/null"
|
||||
codec => json
|
||||
}
|
||||
}
|
||||
|
||||
filter {
|
||||
date {
|
||||
match => ["timestamp", "ISO8601"]
|
||||
}
|
||||
}
|
||||
|
||||
output {
|
||||
elasticsearch {
|
||||
hosts => ["elasticsearch:9200"]
|
||||
index => "tornado-elevue-%{+YYYY.MM.dd}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"title": "Tornado+EleVue 应用监控",
|
||||
"uid": "tornado-elevue",
|
||||
"version": 1,
|
||||
"timezone": "browser",
|
||||
"refresh": "30s",
|
||||
"schemaVersion": 39,
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "HTTP 请求数",
|
||||
"type": "timeseries",
|
||||
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum(rate(http_requests_total{job=\"tornado_elevue\"}[5m]))",
|
||||
"legendFormat": "请求/秒"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "请求响应时间",
|
||||
"type": "timeseries",
|
||||
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
|
||||
"targets": [
|
||||
{
|
||||
"expr": "histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{job=\"tornado_elevue\"}[5m])) by (le))",
|
||||
"legendFormat": "P95"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
# Kubernetes 部署(可选)
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: tornado-elevue
|
||||
namespace: default
|
||||
labels:
|
||||
app: tornado-elevue
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: tornado-elevue
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: tornado-elevue
|
||||
spec:
|
||||
containers:
|
||||
- name: tornado-elevue
|
||||
image: registry.example.com/tornado-elevue:latest
|
||||
ports:
|
||||
- containerPort: 8041
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: tornado-elevue-config
|
||||
resources:
|
||||
requests:
|
||||
cpu: 250m
|
||||
memory: 512Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 1Gi
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /api/v1/health
|
||||
port: 8041
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /api/v1/health
|
||||
port: 8041
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
volumeMounts:
|
||||
- name: uploads
|
||||
mountPath: /data/apps/uploads
|
||||
volumes:
|
||||
- name: uploads
|
||||
persistentVolumeClaim:
|
||||
claimName: tornado-elevue-uploads
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: tornado-elevue-config
|
||||
data:
|
||||
TORNADO_ENV: production
|
||||
TORNADO_PORT: "8041"
|
||||
@@ -0,0 +1,18 @@
|
||||
# Kubernetes Ingress(可选)
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: tornado-elevue
|
||||
namespace: default
|
||||
spec:
|
||||
rules:
|
||||
- host: api.example.com
|
||||
http:
|
||||
paths:
|
||||
- path: /api
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: tornado-elevue
|
||||
port:
|
||||
name: http
|
||||
@@ -0,0 +1,14 @@
|
||||
# Kubernetes 服务(可选)
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: tornado-elevue
|
||||
namespace: default
|
||||
spec:
|
||||
selector:
|
||||
app: tornado-elevue
|
||||
ports:
|
||||
- name: http
|
||||
port: 8041
|
||||
targetPort: 8041
|
||||
type: ClusterIP
|
||||
@@ -0,0 +1,35 @@
|
||||
# DjangoAdmin Tornado+EleVue 反向代理配置
|
||||
# 前端(Vue)静态资源 + 后端API代理
|
||||
|
||||
upstream tornado_backend {
|
||||
server 127.0.0.1:8041;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
charset utf-8;
|
||||
client_max_body_size 50m;
|
||||
|
||||
# 后端 API(统一 /api 前缀)
|
||||
location /api/ {
|
||||
proxy_pass http://tornado_backend;
|
||||
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;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# 上传文件访问
|
||||
location /uploads/ {
|
||||
alias /data/apps/uploads/;
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
# 前端静态资源(独立部署时使用)
|
||||
# location / {
|
||||
# root /data/frontend/dist;
|
||||
# try_files $uri $uri/ /index.html;
|
||||
# }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# Prometheus 监控配置
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: tornado_elevue
|
||||
static_configs:
|
||||
- targets: ["127.0.0.1:8041"]
|
||||
@@ -0,0 +1,21 @@
|
||||
# Supervisor 进程管理配置
|
||||
; 安装: apt install supervisor
|
||||
; 软链: ln -s /data/apps/deploy/supervisor/supervisor.conf /etc/supervisor/conf.d/tornado_elevue.conf
|
||||
; 重载: supervisorctl update && supervisorctl reload
|
||||
|
||||
[program:tornado_elevue]
|
||||
directory=/data/apps
|
||||
command=python app.py
|
||||
user=root
|
||||
autostart=true
|
||||
autorestart=true
|
||||
startsecs=5
|
||||
startretries=10
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/data/apps/logs/supervisor_stdout.log
|
||||
stderr_logfile=/data/apps/logs/supervisor_stderr.log
|
||||
stdout_logfile_maxbytes=100MB
|
||||
stdout_logfile_backups=10
|
||||
environment=TORNADO_ENV="production",PYTHONUNBUFFERED="1"
|
||||
Reference in New Issue
Block a user