P3 A1+M5: agent memory tuning profile and XUI_PPROF gate on both agent entries
This commit is contained in:
+21
-1
@@ -3,7 +3,7 @@
|
||||
// panel binary under the "agent" subcommand, shipping the whole web
|
||||
// panel and the embedded frontend to every node. This entry links only
|
||||
// the agent's own dependency closure (internal/agent plus config,
|
||||
// logger, selfupdate, xray-api types and two util leaves), so the node
|
||||
// logger, selfupdate, xray-api types and a few util leaves), so the node
|
||||
// artifact is a fraction of the panel binary while remaining a drop-in
|
||||
// replacement for it:
|
||||
//
|
||||
@@ -25,6 +25,8 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
@@ -33,6 +35,7 @@ import (
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/agent"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/config"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/logger"
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/util/sys"
|
||||
|
||||
"github.com/op/go-logging"
|
||||
)
|
||||
@@ -96,6 +99,23 @@ func runAgent(args []string) {
|
||||
logger.InitLogger(logging.INFO)
|
||||
log.Printf("Starting 3x-ui agent (node: %s)", cfg.NodeName)
|
||||
|
||||
// Agent memory profile (ITEM-P3 A1/M5): the same runtime tuning
|
||||
// family as the panel, with the agent's tighter budget, plus the
|
||||
// periodic release the panel runs through its job scheduler (the
|
||||
// agent has no scheduler), plus the panel's XUI_PPROF gate.
|
||||
for _, line := range sys.ApplyAgentMemoryTuning() {
|
||||
log.Println(line)
|
||||
}
|
||||
sys.StartPeriodicMemoryRelease()
|
||||
if os.Getenv("XUI_PPROF") == "true" {
|
||||
go func() {
|
||||
log.Println("pprof profiling server listening on 127.0.0.1:6060")
|
||||
if err := http.ListenAndServe("127.0.0.1:6060", nil); err != nil {
|
||||
log.Printf("pprof server stopped: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
ag := agent.New(cfg)
|
||||
|
||||
// Handle shutdown signals
|
||||
|
||||
Reference in New Issue
Block a user