Chunk manager init

This commit is contained in:
Ben Sarmiento
2023-11-06 01:22:56 +01:00
parent 90aaceec77
commit a39c72523d
5 changed files with 31 additions and 74 deletions

View File

@@ -13,6 +13,7 @@ import (
"github.com/debridmediamanager.com/zurg/internal/net"
"github.com/debridmediamanager.com/zurg/internal/torrent"
"github.com/debridmediamanager.com/zurg/internal/zfs"
"github.com/debridmediamanager.com/zurg/pkg/chunk"
"github.com/debridmediamanager.com/zurg/pkg/logutil"
"github.com/hashicorp/golang-lru/v2/expirable"
)
@@ -28,10 +29,10 @@ func main() {
cache := expirable.NewLRU[string, string](1e4, nil, time.Hour)
t := torrent.NewTorrentManager(config, cache)
torrentMgr := torrent.NewTorrentManager(config, cache)
mux := http.NewServeMux()
net.Router(mux, config, t, cache)
net.Router(mux, config, torrentMgr, cache)
addr := fmt.Sprintf(":%s", config.GetPort())
server := &http.Server{Addr: addr, Handler: mux}
@@ -43,6 +44,18 @@ func main() {
}
}
chunkMgr, err := chunk.NewManager(
"",
10485760,
4,
4,
4,
32,
config)
if nil != err {
log.Panicf("Failed to initialize chunk manager: %v", err)
}
shutdown := make(chan os.Signal, 1)
signal.Notify(shutdown, os.Interrupt, syscall.SIGTERM)
@@ -66,7 +79,7 @@ func main() {
}
}()
log.Infof("Mounting on %s", mountPoint)
if err := zfs.Mount(mountPoint, config, t); err != nil {
if err := zfs.Mount(mountPoint, config, torrentMgr, chunkMgr); err != nil {
log.Panicf("Failed to mount: %v", err)
}
}()