- Add more limit to number of gorutines

- Add gorutine stats to logs
- Fix issues with repair
This commit is contained in:
Mukhtar Akere
2025-03-27 08:24:40 +01:00
parent 7bd38736b1
commit d49fbea60f
11 changed files with 163 additions and 139 deletions

View File

@@ -3,6 +3,7 @@ package decypharr
import (
"context"
"fmt"
"github.com/rs/zerolog"
"github.com/sirrobot01/debrid-blackhole/internal/config"
"github.com/sirrobot01/debrid-blackhole/internal/logger"
"github.com/sirrobot01/debrid-blackhole/pkg/proxy"
@@ -14,12 +15,26 @@ import (
"github.com/sirrobot01/debrid-blackhole/pkg/webdav"
"github.com/sirrobot01/debrid-blackhole/pkg/worker"
"os"
"runtime"
"runtime/debug"
"strconv"
"sync"
"syscall"
"time"
)
func monitorGoroutines(interval time.Duration, _log zerolog.Logger) {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
_log.Debug().Msgf("Current goroutines: %d", runtime.NumGoroutine())
}
}
}
func Start(ctx context.Context) error {
if umaskStr := os.Getenv("UMASK"); umaskStr != "" {
@@ -106,6 +121,11 @@ func Start(ctx context.Context) error {
})
}
safeGo(func() error {
monitorGoroutines(1*time.Minute, _log)
return nil
})
go func() {
wg.Wait()
close(errChan)