use a new thread safe map
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@@ -14,13 +13,11 @@ import (
|
||||
"github.com/debridmediamanager.com/zurg/internal/net"
|
||||
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||
"github.com/debridmediamanager.com/zurg/internal/version"
|
||||
"github.com/debridmediamanager.com/zurg/internal/zfs"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/chunk"
|
||||
zurghttp "github.com/debridmediamanager.com/zurg/pkg/http"
|
||||
|
||||
// zurghttp "github.com/debridmediamanager.com/zurg/pkg/http"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/realdebrid"
|
||||
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||
"github.com/winfsp/cgofuse/fuse"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -65,29 +62,29 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
log.Debugf("Initializing chunk manager, cores: %d", runtime.NumCPU())
|
||||
client := zurghttp.NewHTTPClient(config.GetToken(), 10, config)
|
||||
chunkMgr, err := chunk.NewManager(
|
||||
"", // in-memory chunks
|
||||
10485760, // 10MB chunk size
|
||||
max(runtime.NumCPU()/2, 1), // 8 cores/2 = 4 chunks to load ahead
|
||||
max(runtime.NumCPU()/2, 1), // 4 check threads
|
||||
max(runtime.NumCPU()-1, 1), // number of chunks that should be read ahead
|
||||
runtime.NumCPU()*2, // total chunks kept in memory
|
||||
torrentMgr,
|
||||
client)
|
||||
if nil != err {
|
||||
log.Panicf("Failed to initialize chunk manager: %v", err)
|
||||
}
|
||||
// log.Debugf("Initializing chunk manager, cores: %d", runtime.NumCPU())
|
||||
// client := zurghttp.NewHTTPClient(config.GetToken(), 10, config)
|
||||
// chunkMgr, err := chunk.NewManager(
|
||||
// "", // in-memory chunks
|
||||
// 10485760, // 10MB chunk size
|
||||
// max(runtime.NumCPU()/2, 1), // 8 cores/2 = 4 chunks to load ahead
|
||||
// max(runtime.NumCPU()/2, 1), // 4 check threads
|
||||
// max(runtime.NumCPU()-1, 1), // number of chunks that should be read ahead
|
||||
// runtime.NumCPU()*2, // total chunks kept in memory
|
||||
// torrentMgr,
|
||||
// client)
|
||||
// if nil != err {
|
||||
// log.Panicf("Failed to initialize chunk manager: %v", err)
|
||||
// }
|
||||
|
||||
fs := zfs.NewZurgFS(torrentMgr, config, chunkMgr, logutil.NewLogger().Named("zfs"))
|
||||
host := fuse.NewFileSystemHost(fs)
|
||||
go func() {
|
||||
log.Infof("Mounting on %s", config.GetMountPoint())
|
||||
if err := zfs.Mount(host, config); err != nil {
|
||||
log.Panicf("Failed to mount: %v", err)
|
||||
}
|
||||
}()
|
||||
// fs := zfs.NewZurgFS(torrentMgr, config, chunkMgr, logutil.NewLogger().Named("zfs"))
|
||||
// host := fuse.NewFileSystemHost(fs)
|
||||
// go func() {
|
||||
// log.Infof("Mounting on %s", config.GetMountPoint())
|
||||
// if err := zfs.Mount(host, config); err != nil {
|
||||
// log.Panicf("Failed to mount: %v", err)
|
||||
// }
|
||||
// }()
|
||||
|
||||
<-shutdown
|
||||
|
||||
@@ -97,9 +94,9 @@ func main() {
|
||||
if err := server.Shutdown(ctx); err != nil {
|
||||
log.Errorf("Server shutdown error: %v\n", err)
|
||||
}
|
||||
if err := zfs.Unmount(host); err != nil {
|
||||
log.Errorf("Unmount error: %v\n", err)
|
||||
}
|
||||
// if err := zfs.Unmount(host); err != nil {
|
||||
// log.Errorf("Unmount error: %v\n", err)
|
||||
// }
|
||||
|
||||
log.Info("BYE")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user