- Add more limit to number of gorutines
- Add gorutine stats to logs - Fix issues with repair
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user