mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-04 17:02:26 +08:00
fix
This commit is contained in:
@@ -33,4 +33,6 @@ func init() {
|
|||||||
fmt.Println(`OpenAI base URL is invalid.`)
|
fmt.Println(`OpenAI base URL is invalid.`)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.MkdirAll(StaticDir+`/tmp`, 0777)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"project/config"
|
"project/config"
|
||||||
"project/util"
|
"project/util"
|
||||||
"project/zj"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,7 +20,7 @@ func (pr *row) fetchRemote() (ab []byte, ok bool, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
zj.J(`real url`, u.String())
|
// zj.J(`real url`, u.String())
|
||||||
|
|
||||||
req, err := http.NewRequest(r.Method, u.String(), bytes.NewReader(r.Body))
|
req, err := http.NewRequest(r.Method, u.String(), bytes.NewReader(r.Body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func doMetrics(ab []byte, cached bool, r *http.Request, req *pb.Req) {
|
|||||||
o := &pb.Rsp{}
|
o := &pb.Rsp{}
|
||||||
err := json.Unmarshal(ab, o)
|
err := json.Unmarshal(ab, o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zj.J(`unmarshal fail`, err)
|
zj.W(`unmarshal fail`, err)
|
||||||
util.WriteFile(`metrics-json-fail`, ab)
|
util.WriteFile(`metrics-json-fail`, ab)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package core
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"project/pb"
|
"project/pb"
|
||||||
"project/zj"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -13,8 +12,8 @@ func (c *Core) add(req *pb.Req, hr *http.Request) (pr *row, cached bool) {
|
|||||||
|
|
||||||
c.mux.Lock()
|
c.mux.Lock()
|
||||||
pr, ok := c.pool[hash]
|
pr, ok := c.pool[hash]
|
||||||
if false && ok {
|
if ok {
|
||||||
zj.F(`hit %x`, hash)
|
// zj.F(`hit %x`, hash)
|
||||||
c.mux.Unlock()
|
c.mux.Unlock()
|
||||||
cached = true
|
cached = true
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"project/pb"
|
"project/pb"
|
||||||
"project/util"
|
"project/util"
|
||||||
"project/zj"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Core) getAB(p *pb.Req, r *http.Request) (ab []byte, cached bool, err error) {
|
func (c *Core) getAB(p *pb.Req, r *http.Request) (ab []byte, cached bool, err error) {
|
||||||
@@ -67,7 +66,7 @@ func req(w http.ResponseWriter, r *http.Request) (p *pb.Req, err error) {
|
|||||||
ContentType: contentType,
|
ContentType: contentType,
|
||||||
Body: ab,
|
Body: ab,
|
||||||
}
|
}
|
||||||
zj.F(`%x %s %s %s`, p.Hash(), method, url, contentType)
|
// zj.F(`%x %s %s %s`, p.Hash(), method, url, contentType)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"project/metrics"
|
"project/metrics"
|
||||||
"project/zj"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var errSkip = errors.New(`skip`)
|
var errSkip = errors.New(`skip`)
|
||||||
@@ -31,7 +30,7 @@ func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
err500(w)
|
err500(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
zj.J(`cached`, cached)
|
// zj.J(`cached`, cached)
|
||||||
|
|
||||||
w.Header().Add(`Content-Type`, `application/json`)
|
w.Header().Add(`Content-Type`, `application/json`)
|
||||||
w.Write(ab)
|
w.Write(ab)
|
||||||
|
|||||||
Reference in New Issue
Block a user