perf: flush response after response handled (close #364)
This commit is contained in:
parent
2a527ee436
commit
7bddc73b96
@ -55,6 +55,8 @@ var EmailDomainWhitelist = []string{
|
|||||||
"foxmail.com",
|
"foxmail.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var DebugEnabled = os.Getenv("DEBUG") == "true"
|
||||||
|
|
||||||
var LogConsumeEnabled = true
|
var LogConsumeEnabled = true
|
||||||
|
|
||||||
var SMTPServer = ""
|
var SMTPServer = ""
|
||||||
|
@ -5,13 +5,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"one-api/common"
|
"one-api/common"
|
||||||
"one-api/model"
|
"one-api/model"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -308,6 +307,7 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
|||||||
var textResponse TextResponse
|
var textResponse TextResponse
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
c.Writer.Flush()
|
||||||
if consumeQuota {
|
if consumeQuota {
|
||||||
quota := 0
|
quota := 0
|
||||||
completionRatio := 1.0
|
completionRatio := 1.0
|
||||||
|
3
main.go
3
main.go
@ -26,6 +26,9 @@ func main() {
|
|||||||
if os.Getenv("GIN_MODE") != "debug" {
|
if os.Getenv("GIN_MODE") != "debug" {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
}
|
}
|
||||||
|
if common.DebugEnabled {
|
||||||
|
common.SysLog("running in debug mode")
|
||||||
|
}
|
||||||
// Initialize SQL Database
|
// Initialize SQL Database
|
||||||
err := model.InitDB()
|
err := model.InitDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -57,6 +57,9 @@ func InitDB() (err error) {
|
|||||||
}
|
}
|
||||||
common.SysLog("database connected")
|
common.SysLog("database connected")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if common.DebugEnabled {
|
||||||
|
db = db.Debug()
|
||||||
|
}
|
||||||
DB = db
|
DB = db
|
||||||
sqlDB, err := DB.DB()
|
sqlDB, err := DB.DB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user