feat(agentcompat): add dashboard listener hooks

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
naiba
2026-07-20 04:33:38 +00:00
co-authored by naiba/CloudCode
parent 3f6de265a0
commit aee586baad
6 changed files with 484 additions and 3 deletions
+11 -3
View File
@@ -8,7 +8,6 @@ import (
"flag"
"fmt"
"log"
"net"
"net/http"
"os"
"runtime/debug"
@@ -140,10 +139,18 @@ func main() {
log.Fatal(err)
}
l, err := net.Listen("tcp", fmt.Sprintf("%s:%d", singleton.Conf.ListenHost, singleton.Conf.ListenPort))
l, err := openDashboardListener("tcp", dashboardListenerAddress(singleton.Conf.ListenHost, singleton.Conf.ListenPort), dashboardHTTPListener)
if err != nil {
log.Fatal(err)
}
receiptListener, err := openReceiptGateListener()
if err != nil {
log.Fatal(err)
}
if receiptListener != nil {
defer receiptListener.Close()
rpc.SetReceiptGateListener(receiptListener)
}
singleton.CleanMonitorHistory()
rpc.DispatchKeepalive()
@@ -185,7 +192,7 @@ func main() {
log.Printf("NEZHA>> Dashboard::START ON %s:%d", singleton.Conf.ListenHost, singleton.Conf.ListenPort)
if singleton.Conf.HTTPS.ListenPort != 0 {
go func() {
errChan <- muxServerHTTPS.ListenAndServeTLS(singleton.Conf.HTTPS.TLSCertPath, singleton.Conf.HTTPS.TLSKeyPath)
errChan <- serveDashboardHTTPS(muxServerHTTPS, singleton.Conf.HTTPS.TLSCertPath, singleton.Conf.HTTPS.TLSKeyPath)
}()
log.Printf("NEZHA>> Dashboard::START ON %s:%d", singleton.Conf.ListenHost, singleton.Conf.HTTPS.ListenPort)
}
@@ -195,6 +202,7 @@ func main() {
return <-errChan
}, func(c context.Context) error {
log.Println("NEZHA>> Graceful::START")
rpc.CloseReceiptGate()
singleton.RecordTransferHourlyUsage()
singleton.CloseTSDB()
log.Println("NEZHA>> Graceful::END")