Implement proper checks for new torrents

This commit is contained in:
Ben Sarmiento
2023-12-02 17:37:18 +01:00
parent 910e5a4998
commit a8e5744481
5 changed files with 207 additions and 139 deletions

View File

@@ -16,12 +16,16 @@ import (
"github.com/dgraph-io/ristretto"
"github.com/julienschmidt/httprouter"
"github.com/panjf2000/ants/v2"
_ "net/http/pprof" // Register pprof
)
func MainApp(configPath string) {
log := logutil.NewLogger()
zurglog := log.Named("zurg")
zurglog.Debugf("PID: %d", os.Getpid())
config, configErr := config.LoadZurgConfig(configPath, log.Named("config"))
if configErr != nil {
zurglog.Errorf("Config failed to load: %v", configErr)
@@ -61,6 +65,13 @@ func MainApp(configPath string) {
handler.RedirectFixedPath = true
router.ApplyRouteTable(handler, getfile, torrentMgr, config, rd, log.Named("router"))
go func() {
if err := netHttp.ListenAndServe(":6060", nil); err != nil && err != netHttp.ErrServerClosed {
zurglog.Errorf("Failed to start pprof: %v", err)
os.Exit(1)
}
}()
addr := fmt.Sprintf("%s:%s", config.GetHost(), config.GetPort())
zurglog.Infof("Starting server on %s", addr)
if err := netHttp.ListenAndServe(addr, handler); err != nil && err != netHttp.ErrServerClosed {