Commit 8874d192 by CaIon

Make quota logging synchronous and delay startup log

parent bff701b0
...@@ -210,9 +210,6 @@ func main() { ...@@ -210,9 +210,6 @@ func main() {
port = strconv.Itoa(*common.Port) port = strconv.Itoa(*common.Port)
} }
// Log startup success message
common.LogStartupSuccess(startTime, port)
srv := &http.Server{ srv := &http.Server{
Addr: ":" + port, Addr: ":" + port,
Handler: server, Handler: server,
...@@ -224,6 +221,8 @@ func main() { ...@@ -224,6 +221,8 @@ func main() {
} }
}() }()
common.LogStartupSuccess(startTime, port)
quit := make(chan os.Signal, 1) quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
sig := <-quit sig := <-quit
......
...@@ -13,7 +13,6 @@ import ( ...@@ -13,7 +13,6 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/bytedance/gopkg/util/gopool"
"gorm.io/gorm" "gorm.io/gorm"
) )
...@@ -389,7 +388,6 @@ func RecordConsumeLog(c *gin.Context, userId int, params RecordConsumeLogParams) ...@@ -389,7 +388,6 @@ func RecordConsumeLog(c *gin.Context, userId int, params RecordConsumeLogParams)
logger.LogError(c, "failed to record log: "+err.Error()) logger.LogError(c, "failed to record log: "+err.Error())
} }
if common.DataExportEnabled { if common.DataExportEnabled {
gopool.Go(func() {
LogQuotaData(QuotaDataLogParams{ LogQuotaData(QuotaDataLogParams{
UserID: userId, UserID: userId,
Username: username, Username: username,
...@@ -402,7 +400,6 @@ func RecordConsumeLog(c *gin.Context, userId int, params RecordConsumeLogParams) ...@@ -402,7 +400,6 @@ func RecordConsumeLog(c *gin.Context, userId int, params RecordConsumeLogParams)
ChannelID: params.ChannelId, ChannelID: params.ChannelId,
NodeName: common.NodeName, NodeName: common.NodeName,
}) })
})
} }
} }
...@@ -454,7 +451,6 @@ func RecordTaskBillingLog(params RecordTaskBillingLogParams) { ...@@ -454,7 +451,6 @@ func RecordTaskBillingLog(params RecordTaskBillingLogParams) {
if nodeName == "" { if nodeName == "" {
nodeName = common.NodeName nodeName = common.NodeName
} }
gopool.Go(func() {
LogQuotaData(QuotaDataLogParams{ LogQuotaData(QuotaDataLogParams{
UserID: params.UserId, UserID: params.UserId,
Username: username, Username: username,
...@@ -466,7 +462,6 @@ func RecordTaskBillingLog(params RecordTaskBillingLogParams) { ...@@ -466,7 +462,6 @@ func RecordTaskBillingLog(params RecordTaskBillingLogParams) {
ChannelID: params.ChannelId, ChannelID: params.ChannelId,
NodeName: nodeName, NodeName: nodeName,
}) })
})
} }
} }
......
This diff was suppressed by a .gitattributes entry.
<svg width="1600" height="900" viewBox="0 0 1600 900" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="bg" x1="140" y1="30" x2="1450" y2="880" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#F3FCFF"/>
<stop offset="0.46" stop-color="#FFFFFF"/>
<stop offset="1" stop-color="#FFF6FD"/>
</linearGradient>
<linearGradient id="logoGradient" x1="430" y1="252" x2="1110" y2="616" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#22D3EE"/>
<stop offset="0.48" stop-color="#7C3AED"/>
<stop offset="1" stop-color="#F15BB5"/>
</linearGradient>
<linearGradient id="lineGradient" x1="180" y1="120" x2="1440" y2="780" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#22D3EE" stop-opacity="0.28"/>
<stop offset="0.52" stop-color="#7C3AED" stop-opacity="0.22"/>
<stop offset="1" stop-color="#F15BB5" stop-opacity="0.28"/>
</linearGradient>
<linearGradient id="softBand" x1="300" y1="190" x2="1320" y2="740" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#22D3EE" stop-opacity="0.14"/>
<stop offset="0.5" stop-color="#7C3AED" stop-opacity="0.1"/>
<stop offset="1" stop-color="#F15BB5" stop-opacity="0.14"/>
</linearGradient>
<filter id="softShadow" x="-20%" y="-20%" width="140%" height="140%" color-interpolation-filters="sRGB">
<feDropShadow dx="0" dy="24" stdDeviation="34" flood-color="#64748B" flood-opacity="0.16"/>
</filter>
<filter id="logoShadow" x="-30%" y="-30%" width="160%" height="160%" color-interpolation-filters="sRGB">
<feDropShadow dx="0" dy="18" stdDeviation="24" flood-color="#7C3AED" flood-opacity="0.18"/>
</filter>
<clipPath id="logoClip">
<circle cx="800" cy="206" r="62"/>
</clipPath>
</defs>
<rect width="1600" height="900" rx="0" fill="url(#bg)"/>
<g opacity="0.65">
<path d="M-90 654C145 538 294 690 495 594C702 495 678 278 908 252C1129 227 1214 421 1697 277" stroke="url(#lineGradient)" stroke-width="2.4"/>
<path d="M-62 266C184 413 331 178 539 280C772 394 782 632 1008 624C1216 617 1332 424 1664 548" stroke="url(#lineGradient)" stroke-width="2"/>
<path d="M122 780C392 624 561 779 742 622C905 480 806 323 992 222C1172 124 1322 196 1512 96" stroke="url(#lineGradient)" stroke-width="1.7"/>
</g>
<g opacity="0.22">
<path d="M204 154H1396" stroke="#7C3AED" stroke-width="1"/>
<path d="M204 746H1396" stroke="#22D3EE" stroke-width="1"/>
<path d="M280 80V820" stroke="#F15BB5" stroke-width="1"/>
<path d="M1320 80V820" stroke="#22D3EE" stroke-width="1"/>
</g>
<g filter="url(#softShadow)">
<path d="M310 648C393 543 504 498 637 512C742 524 837 579 941 559C1075 533 1173 414 1291 457C1376 488 1420 580 1428 665C1284 741 1117 784 932 790C702 797 492 750 310 648Z" fill="url(#softBand)"/>
</g>
<g opacity="0.9">
<circle cx="376" cy="232" r="7" fill="#22D3EE"/>
<circle cx="1266" cy="236" r="7" fill="#F15BB5"/>
<circle cx="1328" cy="642" r="6" fill="#7C3AED"/>
<circle cx="254" cy="606" r="5" fill="#F15BB5"/>
<circle cx="1172" cy="154" r="4" fill="#22D3EE"/>
<circle cx="506" cy="760" r="4" fill="#7C3AED"/>
</g>
<g opacity="0.82">
<path d="M1190 358L1202 386L1232 398L1202 410L1190 438L1178 410L1148 398L1178 386L1190 358Z" fill="#22D3EE"/>
<path d="M420 416L430 440L456 450L430 460L420 484L410 460L384 450L410 440L420 416Z" fill="#F15BB5"/>
<path d="M1074 718L1083 739L1105 748L1083 757L1074 778L1065 757L1043 748L1065 739L1074 718Z" fill="#7C3AED"/>
</g>
<g transform="translate(0 10)">
<g filter="url(#logoShadow)">
<circle cx="800" cy="206" r="78" fill="#FFFFFF"/>
<circle cx="800" cy="206" r="77" stroke="#E8F3FF" stroke-width="2"/>
<image href="/Users/caion/GolandProjects/new-api/web/default/public/logo.png" x="738" y="144" width="124" height="124" clip-path="url(#logoClip)" preserveAspectRatio="xMidYMid meet"/>
</g>
<text x="800" y="344" text-anchor="middle"
font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"
font-size="46" font-weight="760" letter-spacing="0" fill="#0F172A">NewAPI</text>
<text x="800" y="516" text-anchor="middle"
font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"
font-size="170" font-weight="860" letter-spacing="0" fill="url(#logoGradient)">40K</text>
<text x="800" y="616" text-anchor="middle"
font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"
font-size="76" font-weight="780" letter-spacing="0" fill="#101828">Stars</text>
<text x="800" y="688" text-anchor="middle"
font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"
font-size="34" font-weight="560" letter-spacing="0" fill="#475569">Thank you, builders</text>
</g>
<g transform="translate(104 86)">
<image href="/Users/caion/GolandProjects/new-api/web/default/public/logo.png" x="0" y="0" width="42" height="42" preserveAspectRatio="xMidYMid meet"/>
<text x="58" y="30"
font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"
font-size="26" font-weight="730" letter-spacing="0" fill="#162033">NewAPI</text>
</g>
<g transform="translate(1262 96)">
<rect x="0" y="0" width="234" height="54" rx="27" fill="#FFFFFF" fill-opacity="0.78" stroke="#D7E7F5"/>
<text x="117" y="35" text-anchor="middle"
font-family="Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif"
font-size="23" font-weight="660" letter-spacing="0" fill="#334155">newapi.ai</text>
</g>
<g transform="translate(118 774)">
<path d="M0 22H246" stroke="#22D3EE" stroke-width="5" stroke-linecap="round"/>
<path d="M281 22H464" stroke="#7C3AED" stroke-width="5" stroke-linecap="round"/>
<path d="M500 22H652" stroke="#F15BB5" stroke-width="5" stroke-linecap="round"/>
</g>
</svg>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment