diff --git a/torrent/assets/js/general.js b/torrent/assets/js/general.js index e723052..03c14f9 100644 --- a/torrent/assets/js/general.js +++ b/torrent/assets/js/general.js @@ -1,6 +1,5 @@ GeneralChart.init(); var cacheChart = new SingleBarChart("chart-cache", "Cache disk"); -var workerChart = new SingleBarChart("chart-workers", "Workers"); fetchData(); setInterval(function () { @@ -22,7 +21,6 @@ function fetchData() { GeneralChart.update(download, upload); cacheChart.update(stats.cacheFilled, stats.cacheCapacity - stats.cacheFilled); - workerChart.update(0, stats.poolFree - stats.poolCap); document.getElementById("down-speed-text").innerText = Humanize.bytes(download, 1024) + "/s"; diff --git a/torrent/assets/js/single_bar_chart.js b/torrent/assets/js/single_bar_chart.js index 524df42..1324aa9 100644 --- a/torrent/assets/js/single_bar_chart.js +++ b/torrent/assets/js/single_bar_chart.js @@ -3,7 +3,7 @@ function SingleBarChart(id, name) { this._used = []; this._free = []; this._chart = new Chart(ctx, { - type: 'bar', + type: 'horizontalBar', data: { labels:[name], datasets: [{ diff --git a/torrent/cmd/distribyted/main.go b/torrent/cmd/distribyted/main.go index 2bb75b0..194f2b5 100644 --- a/torrent/cmd/distribyted/main.go +++ b/torrent/cmd/distribyted/main.go @@ -19,7 +19,6 @@ import ( "github.com/gin-contrib/static" "github.com/gin-gonic/gin" "github.com/goccy/go-yaml" - "github.com/panjf2000/ants/v2" "github.com/shurcooL/httpfs/html/vfstemplate" ) @@ -67,13 +66,8 @@ func main() { log.Fatal(err) } - pool, err := ants.NewPool(100) - if err != nil { - log.Fatal(err) - } - ss := stats.NewTorrent() - mountService := mount.NewHandler(c, pool, ss) + mountService := mount.NewHandler(c, ss) sigChan := make(chan os.Signal) signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM) @@ -82,8 +76,6 @@ func main() { <-sigChan log.Println("Closing torrent client...") c.Close() - log.Println("Releasing execution pool...") - pool.Release() log.Println("Unmounting fuse filesystem...") mountService.Close() @@ -123,8 +115,6 @@ func main() { "cacheItems": fc.Info().NumItems, "cacheFilled": fc.Info().Filled / 1024 / 1024, "cacheCapacity": fc.Info().Capacity / 1024 / 1024, - "poolCap": pool.Cap(), - "poolFree": pool.Free(), "torrentStats": ss.GlobalStats(), }) }) diff --git a/torrent/go.mod b/torrent/go.mod index e6a432b..8e48969 100644 --- a/torrent/go.mod +++ b/torrent/go.mod @@ -23,7 +23,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.1 // indirect github.com/mschoch/smat v0.2.0 // indirect - github.com/panjf2000/ants/v2 v2.3.1 github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 github.com/stretchr/testify v1.4.0 github.com/tinylib/msgp v1.1.2 // indirect diff --git a/torrent/go.sum b/torrent/go.sum index b83c56c..f8c300a 100644 --- a/torrent/go.sum +++ b/torrent/go.sum @@ -287,8 +287,6 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/panjf2000/ants/v2 v2.3.1 h1:9iOZHO5XlSO1Gs5K7x06uDFy8bkicWlhOKGh/TufAZg= -github.com/panjf2000/ants/v2 v2.3.1/go.mod h1:LtwNaBX6OeF5qRtQlaeGndalVwJlS2ueur7uwoAHbPA= github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= diff --git a/torrent/mount/handler.go b/torrent/mount/handler.go index bdc91da..202c70b 100644 --- a/torrent/mount/handler.go +++ b/torrent/mount/handler.go @@ -11,7 +11,6 @@ import ( "github.com/anacrolix/torrent" "github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fuse" - "github.com/panjf2000/ants/v2" ) type Handler struct { @@ -19,16 +18,14 @@ type Handler struct { s *stats.Torrent opts *fs.Options - pool *ants.Pool servers map[string]*fuse.Server } -func NewHandler(c *torrent.Client, pool *ants.Pool, s *stats.Torrent) *Handler { +func NewHandler(c *torrent.Client, s *stats.Torrent) *Handler { return &Handler{ c: c, s: s, opts: &fs.Options{}, - pool: pool, servers: make(map[string]*fuse.Server), } } @@ -69,7 +66,7 @@ func (s *Handler) Mount(mpc *config.MountPoint) error { return err } - node := node.NewRoot(torrents, s.pool) + node := node.NewRoot(torrents) server, err := fs.Mount(mpc.Path, node, s.opts) if err != nil { return err diff --git a/torrent/node/root.go b/torrent/node/root.go index dca15af..eb40df9 100644 --- a/torrent/node/root.go +++ b/torrent/node/root.go @@ -8,7 +8,6 @@ import ( "github.com/anacrolix/torrent" "github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fuse" - "github.com/panjf2000/ants/v2" ) var _ fs.NodeOnAdder = &Root{} @@ -16,23 +15,20 @@ var _ fs.NodeGetattrer = &Root{} type Root struct { fs.Inode - pool *ants.Pool torrents []*torrent.Torrent } -func NewRoot(torrents []*torrent.Torrent, pool *ants.Pool) *Root { - return &Root{torrents: torrents, pool: pool} +func NewRoot(torrents []*torrent.Torrent) *Root { + return &Root{torrents: torrents} } func (root *Root) OnAdd(ctx context.Context) { for _, torrent := range root.torrents { - root.pool.Submit(func() { - root.AddChild( - filepath.Clean(torrent.Name()), - root.NewPersistentInode(ctx, &Torrent{t: torrent, pool: root.pool}, fs.StableAttr{ - Mode: syscall.S_IFDIR, - }), true) - }) + root.AddChild( + filepath.Clean(torrent.Name()), + root.NewPersistentInode(ctx, &Torrent{t: torrent}, fs.StableAttr{ + Mode: syscall.S_IFDIR, + }), true) } } diff --git a/torrent/node/torrent.go b/torrent/node/torrent.go index 812750e..34bb562 100644 --- a/torrent/node/torrent.go +++ b/torrent/node/torrent.go @@ -9,7 +9,6 @@ import ( "github.com/anacrolix/torrent" "github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fuse" - "github.com/panjf2000/ants/v2" ) var _ fs.NodeOnAdder = &Torrent{} @@ -18,8 +17,6 @@ var _ fs.NodeGetattrer = &Torrent{} type Torrent struct { fs.Inode t *torrent.Torrent - - pool *ants.Pool } func (folder *Torrent) OnAdd(ctx context.Context) { @@ -27,7 +24,6 @@ func (folder *Torrent) OnAdd(ctx context.Context) { file := file LoadNodeByPath( ctx, - folder.pool, file.Path(), func() (io.ReaderAt, error) { return iio.NewReadAtWrapper(file.NewReader()), nil }, &folder.Inode, diff --git a/torrent/node/utils.go b/torrent/node/utils.go index be4196f..1798111 100644 --- a/torrent/node/utils.go +++ b/torrent/node/utils.go @@ -10,12 +10,11 @@ import ( "github.com/hanwen/go-fuse/v2/fs" "github.com/hanwen/go-fuse/v2/fuse" - "github.com/panjf2000/ants/v2" ) type ReaderFunc func() (io.ReaderAt, error) -func LoadNodeByPath(ctx context.Context, pool *ants.Pool, fp string, reader ReaderFunc, parent *fs.Inode, fileLength int64, pieceLen int32, numPieces int64) { +func LoadNodeByPath(ctx context.Context, fp string, reader ReaderFunc, parent *fs.Inode, fileLength int64, pieceLen int32, numPieces int64) { p := parent dir, base := filepath.Split(filepath.Clean(fp)) for i, component := range strings.Split(dir, "/") { diff --git a/torrent/node/zip.go b/torrent/node/zip.go index b9535b7..37dcef2 100644 --- a/torrent/node/zip.go +++ b/torrent/node/zip.go @@ -50,7 +50,6 @@ func (z *Zip) Opendir(ctx context.Context) syscall.Errno { } LoadNodeByPath( ctx, - nil, f.Name, func() (io.ReaderAt, error) { zfr, err := f.Open() diff --git a/torrent/templates/index.html b/torrent/templates/index.html index 3935e87..8db656a 100644 --- a/torrent/templates/index.html +++ b/torrent/templates/index.html @@ -10,13 +10,15 @@
- +
- +
+
+

-
- -
{{template "common_footer.html"}}