perf: 提升后端高并发承载能力
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"hightube/internal/api"
|
||||
"hightube/internal/chat"
|
||||
"hightube/internal/db"
|
||||
@@ -23,9 +26,16 @@ func main() {
|
||||
// Start the API server in a goroutine so it doesn't block the RTMP server
|
||||
go func() {
|
||||
r := api.SetupRouter(srv)
|
||||
httpServer := &http.Server{
|
||||
Addr: ":8080",
|
||||
Handler: r,
|
||||
ReadHeaderTimeout: 5 * time.Second,
|
||||
IdleTimeout: 60 * time.Second,
|
||||
MaxHeaderBytes: 1 << 20,
|
||||
}
|
||||
monitor.Infof("API server listening on :8080")
|
||||
monitor.Infof("Web console listening on :8080/admin")
|
||||
if err := r.Run(":8080"); err != nil {
|
||||
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
monitor.Errorf("Failed to start API server: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user