fix prod
This commit is contained in:
parent
d756c32ff1
commit
447e367842
38
aicss.ingress
Normal file
38
aicss.ingress
Normal file
@ -0,0 +1,38 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
alb.ingress.kubernetes.io/group.name: xpink-testapi
|
||||
alb.ingress.kubernetes.io/healthcheck-path: /
|
||||
alb.ingress.kubernetes.io/scheme: internet-facing
|
||||
alb.ingress.kubernetes.io/target-type: ip
|
||||
kubectl.kubernetes.io/last-applied-configuration: |
|
||||
{"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{"alb.ingress.kubernetes.io/group.name":"xpink-testapi","alb.ingress.kubernetes.io/healthcheck-path":"/","alb.ingress.kubernetes.io/scheme":"internet-facing","alb.ingress.kubernetes.io/target-type":"ip"},"name":"aicss","namespace":"xpink"},"spec":{"ingressClassName":"alb","rules":[{"host":"aicss.bressx-test.com","http":{"paths":[{"backend":{"service":{"name":"aicss-svc","port":{"number":8081}}},"path":"/","pathType":"Prefix"}]}}]}}
|
||||
creationTimestamp: "2026-02-09T12:32:12Z"
|
||||
finalizers:
|
||||
- group.ingress.k8s.aws/xpink-testapi
|
||||
generation: 1
|
||||
name: aicss
|
||||
namespace: xpink
|
||||
resourceVersion: "2083488"
|
||||
uid: c624fc3b-17be-484f-8f1c-8d9e22efea6f
|
||||
spec:
|
||||
ingressClassName: alb
|
||||
rules:
|
||||
- host: aicss.bressx-test.com
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: aicss-svc
|
||||
port:
|
||||
number: 8081
|
||||
path: /
|
||||
pathType: Prefix
|
||||
status:
|
||||
loadBalancer:
|
||||
ingress:
|
||||
- hostname: k8s-xpinktestapi-1624c23a1c-1329557297.ap-southeast-1.elb.amazonaws.com
|
||||
ports:
|
||||
- port: 80
|
||||
protocol: ""
|
||||
42
aicss_k8s/test/deployment.yaml
Normal file
42
aicss_k8s/test/deployment.yaml
Normal file
@ -0,0 +1,42 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: aicss-s
|
||||
namespace: xpink
|
||||
labels:
|
||||
app: aicss-s
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: aicss-s
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: aicss-s
|
||||
spec:
|
||||
containers:
|
||||
- name: aicss-s
|
||||
image: 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/aicss_service:test
|
||||
imagePullPolicy: Always
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- sleep 15
|
||||
resources:
|
||||
limits:
|
||||
cpu: 1000m
|
||||
memory: 512Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 10Mi
|
||||
env:
|
||||
- name: IS_TEST
|
||||
value: "true"
|
||||
- name: AICSS_ENV
|
||||
value: "test"
|
||||
imagePullSecrets:
|
||||
- name: coding
|
||||
21
aicss_k8s/test/docker_build.sh
Normal file
21
aicss_k8s/test/docker_build.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
RUN_NAME=aicss_service
|
||||
DOCKER_TAG=test
|
||||
set -e
|
||||
|
||||
go mod tidy
|
||||
|
||||
# 优化编译标志
|
||||
BUILD_FLAGS=(
|
||||
"-trimpath" # 移除文件系统路径,减少二进制大小
|
||||
"-ldflags=-s -w" # 移除符号表和调试信息,减少内存使用
|
||||
)
|
||||
|
||||
# 使用优化的编译标志
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build "${BUILD_FLAGS[@]}" -o output/bin/${RUN_NAME} gofly.go
|
||||
|
||||
echo 'build go success'
|
||||
|
||||
docker build -t 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG} -f Dockerfile .
|
||||
|
||||
docker push 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG}
|
||||
42
aicss_k8s/test/ingress.yaml
Normal file
42
aicss_k8s/test/ingress.yaml
Normal file
@ -0,0 +1,42 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: 2048-ingress
|
||||
namespace: xpink
|
||||
annotations:
|
||||
#alb.ingress.kubernetes.io/subnets: vpc-0b996d24feae0e2d5
|
||||
alb.ingress.kubernetes.io/scheme: internet-facing
|
||||
spec:
|
||||
ingressClassName: alb
|
||||
rules:
|
||||
- host: bressx-test.la
|
||||
http:
|
||||
paths:
|
||||
- path: /api
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8889
|
||||
- path: /admin
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8887
|
||||
- path: /callback
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8888
|
||||
- path: /ws
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: hertz-s
|
||||
port:
|
||||
number: 8891
|
||||
14
aicss_k8s/test/svc.yaml
Normal file
14
aicss_k8s/test/svc.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: aicss-svc
|
||||
namespace: xpink # 如果不是 default,请改成你的 namespace
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: aicss-s
|
||||
ports:
|
||||
- name: http
|
||||
port: 80 # 对外提供的端口
|
||||
targetPort: 8081 # 容器内部监听的端口
|
||||
protocol: TCP
|
||||
6
config/config_test.yaml
Normal file
6
config/config_test.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
mysql_service:
|
||||
server: goder2.cpccmm68qb1d.ap-southeast-1.rds.amazonaws.com
|
||||
port: 3306
|
||||
database: aicss_db
|
||||
username: admin
|
||||
password: vH2GkUxz2398GmDTy^C
|
||||
@ -135,19 +135,18 @@ func SendMessageV2(c *gin.Context) {
|
||||
}
|
||||
if ws.AIAnswerAvailable(guest) {
|
||||
// AI回答
|
||||
ret, err := AIChat(kefuInfo.Name, vistorInfo.VisitorId, content, guest.Conn)
|
||||
if err == nil {
|
||||
guest.AIAnswerCycle++
|
||||
models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, ret, "kefu")
|
||||
ws.VisitorMessage(vistorInfo.VisitorId, ret, kefuInfo)
|
||||
c.JSON(200, gin.H{
|
||||
"code": 200,
|
||||
"msg": "ok",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
logger.Errorf("ai chat failed err:%v,visitorID:%s,content:%s", err, vistorInfo.VisitorId, content)
|
||||
go func() {
|
||||
logger.Debugf("start call ai chat")
|
||||
ret, err := AIChat(kefuInfo.Name, vistorInfo.VisitorId, content, guest.Conn)
|
||||
if err == nil {
|
||||
guest.AIAnswerCycle++
|
||||
models.CreateMessage(kefuInfo.Name, vistorInfo.VisitorId, ret, "kefu")
|
||||
ws.VisitorMessage(vistorInfo.VisitorId, ret, kefuInfo)
|
||||
return
|
||||
} else {
|
||||
logger.Errorf("ai chat failed err:%v,visitorID:%s,content:%s", err, vistorInfo.VisitorId, content)
|
||||
}
|
||||
}()
|
||||
} else if guest.AIAnswerCycle == ws.MaxAIAnswerCycleTimes {
|
||||
guest.AIAnswerCycle++
|
||||
cot := "ai次数用完将进入人工坐席。。。"
|
||||
|
||||
@ -189,6 +189,9 @@ func GetVisitors(c *gin.Context) {
|
||||
kefuId, _ := c.Get("kefu_name")
|
||||
vistors := models.FindVisitorsByKefuId(uint(page), uint(pagesize), kefuId.(string))
|
||||
count := models.CountVisitorsByKefuId(kefuId.(string))
|
||||
for i := range vistors {
|
||||
vistors[i].Name = models.CalcVisitorName(vistors[i])
|
||||
}
|
||||
c.JSON(200, gin.H{
|
||||
"code": 200,
|
||||
"msg": "ok",
|
||||
|
||||
21
docker_build_test.sh
Normal file
21
docker_build_test.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
RUN_NAME=aicss_service
|
||||
DOCKER_TAG=test
|
||||
set -e
|
||||
|
||||
go mod tidy
|
||||
|
||||
# 优化编译标志
|
||||
BUILD_FLAGS=(
|
||||
"-trimpath" # 移除文件系统路径,减少二进制大小
|
||||
"-ldflags=-s -w" # 移除符号表和调试信息,减少内存使用
|
||||
)
|
||||
|
||||
# 使用优化的编译标志
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build "${BUILD_FLAGS[@]}" -o output/bin/${RUN_NAME} gofly.go
|
||||
|
||||
echo 'build go success'
|
||||
|
||||
docker build -t 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG} -f Dockerfile .
|
||||
|
||||
docker push 322814420330.dkr.ecr.ap-southeast-1.amazonaws.com/xpink/${RUN_NAME}:${DOCKER_TAG}
|
||||
@ -1,6 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -132,3 +134,11 @@ func CountVisitorsEveryDay(toId string) []EveryDayNum {
|
||||
toId).Scan(&results)
|
||||
return results
|
||||
}
|
||||
|
||||
func CalcVisitorName(visitor Visitor) string {
|
||||
var isGuest = strings.Contains(visitor.VisitorId, "-")
|
||||
if isGuest {
|
||||
return fmt.Sprintf("游客 | %s ", visitor.VisitorId)
|
||||
}
|
||||
return fmt.Sprintf("用户 | %s ", visitor.VisitorId)
|
||||
}
|
||||
|
||||
@ -784,7 +784,7 @@
|
||||
pagesize: 20,
|
||||
visitor_id: _this.currentGuest,
|
||||
}
|
||||
$.get("/2/messagesPages",params,function(res){
|
||||
$.get("/ai-css/2/messagesPages",params,function(res){
|
||||
let msgList=res.result.list;
|
||||
let existKeys={};
|
||||
for(let i=0;i<_this.msgList.length;i++){
|
||||
|
||||
@ -478,7 +478,7 @@
|
||||
pagesize: 20,
|
||||
visitor_id: _this.visitor.visitor_id,
|
||||
}
|
||||
$.get("/2/messagesPages",params,function(res){
|
||||
$.get("/ai-css/2/messagesPages",params,function(res){
|
||||
let msgList=res.result.list;
|
||||
let existKeys={};
|
||||
for(let i=0;i<_this.msgList.length;i++){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user