Zfs fixes
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -14,7 +13,6 @@ 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/debridmediamanager.com/zurg/pkg/realdebrid"
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
@@ -45,28 +43,6 @@ func main() {
|
||||
addr := fmt.Sprintf("%s:%s", config.GetHost(), config.GetPort())
|
||||
server := &http.Server{Addr: addr, Handler: mux}
|
||||
|
||||
mountPoint := config.GetMountPoint()
|
||||
if _, err := os.Stat(mountPoint); os.IsNotExist(err) {
|
||||
if err := os.Mkdir(mountPoint, 0755); err != nil {
|
||||
log.Panicf("Failed to create mount point: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Debugf("Initializing chunk manager, cores: %d", runtime.NumCPU())
|
||||
// 64kb request size
|
||||
chunkMgr, err := chunk.NewManager(
|
||||
"",
|
||||
524288, // 512kb
|
||||
1, // 1 chunk - load ahead (1MB total)
|
||||
max(runtime.NumCPU()/2, 1), // check threads
|
||||
max(runtime.NumCPU()/2, 1), // load threads
|
||||
runtime.NumCPU()*2,
|
||||
torrentMgr, // max chunks
|
||||
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)
|
||||
|
||||
@@ -78,9 +54,15 @@ func main() {
|
||||
}()
|
||||
|
||||
// Start the mount in a goroutine with panic recovery.
|
||||
mountPoint := config.GetMountPoint()
|
||||
if _, err := os.Stat(mountPoint); os.IsNotExist(err) {
|
||||
if err := os.Mkdir(mountPoint, 0755); err != nil {
|
||||
log.Panicf("Failed to create mount point: %v", err)
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
log.Infof("Mounting on %s", mountPoint)
|
||||
if err := zfs.Mount(mountPoint, config, torrentMgr, chunkMgr); err != nil {
|
||||
if err := zfs.Mount(mountPoint, config, torrentMgr); err != nil {
|
||||
log.Panicf("Failed to mount: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user