访问日志中增加源站状态码

This commit is contained in:
刘祥超
2022-09-16 10:07:40 +08:00
parent c0f0ec43bb
commit 7d0b9208a3
3 changed files with 7 additions and 0 deletions

View File

@@ -68,6 +68,7 @@ type HTTPRequest struct {
filePath string // 请求的文件名仅在读取Root目录下的内容时不为空 filePath string // 请求的文件名仅在读取Root目录下的内容时不为空
origin *serverconfigs.OriginConfig // 源站 origin *serverconfigs.OriginConfig // 源站
originAddr string // 源站实际地址 originAddr string // 源站实际地址
originStatus int32 // 源站响应代码
errors []string // 错误信息 errors []string // 错误信息
rewriteRule *serverconfigs.HTTPRewriteRule // 匹配到的重写规则 rewriteRule *serverconfigs.HTTPRewriteRule // 匹配到的重写规则
rewriteReplace string // 重写规则的目标 rewriteReplace string // 重写规则的目标

View File

@@ -146,6 +146,7 @@ func (this *HTTPRequest) log() {
if this.origin != nil { if this.origin != nil {
accessLog.OriginId = this.origin.Id accessLog.OriginId = this.origin.Id
accessLog.OriginAddress = this.originAddr accessLog.OriginAddress = this.originAddr
accessLog.OriginStatus = this.originStatus
} }
// 请求Body // 请求Body

View File

@@ -320,6 +320,11 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
} }
return return
} }
// 记录相关数据
this.originStatus = int32(resp.StatusCode)
// 恢复源站状态
if !origin.IsOk { if !origin.IsOk {
SharedOriginStateManager.Success(origin, func() { SharedOriginStateManager.Success(origin, func() {
this.reverseProxy.ResetScheduling() this.reverseProxy.ResetScheduling()