This commit is contained in:
royalcat 2024-06-02 22:53:33 +03:00
parent d056ac1167
commit bd75492b02
81 changed files with 822 additions and 1098 deletions
cmd/tstor

View file

@ -18,10 +18,11 @@ import (
"git.kmsign.ru/royalcat/tstor/pkg/rlog"
"git.kmsign.ru/royalcat/tstor/src/config"
"git.kmsign.ru/royalcat/tstor/src/delivery"
"git.kmsign.ru/royalcat/tstor/src/host"
"git.kmsign.ru/royalcat/tstor/src/host/torrent"
"git.kmsign.ru/royalcat/tstor/src/host/vfs"
"git.kmsign.ru/royalcat/tstor/src/sources"
"git.kmsign.ru/royalcat/tstor/src/sources/torrent"
"git.kmsign.ru/royalcat/tstor/src/sources/ytdlp"
"git.kmsign.ru/royalcat/tstor/src/telemetry"
"git.kmsign.ru/royalcat/tstor/src/vfs"
"github.com/go-git/go-billy/v5/osfs"
"github.com/urfave/cli/v2"
@ -90,14 +91,16 @@ func run(configPath string) error {
}
sourceFs := osfs.New(conf.SourceDir, osfs.WithBoundOS())
srv, err := torrent.NewService(sourceFs, conf.TorrentClient)
tsrv, err := torrent.NewService(sourceFs, conf.TorrentClient)
if err != nil {
return fmt.Errorf("error creating service: %w", err)
}
sfs := host.NewHostedFS(
ytdlpsrv := ytdlp.NewService(conf.SourceDir)
sfs := sources.NewHostedFS(
vfs.NewCtxBillyFs("/", ctxbilly.WrapFileSystem(sourceFs)),
srv,
tsrv, ytdlpsrv,
)
sfs = vfs.WrapLogFS(sfs)
@ -174,7 +177,7 @@ func run(configPath string) error {
go func() {
logFilename := filepath.Join(conf.Log.Path, "logs")
err := delivery.New(nil, srv, sfs, logFilename, conf)
err := delivery.New(nil, tsrv, sfs, logFilename, conf)
if err != nil {
log.Error(ctx, "error initializing HTTP server", rlog.Error(err))
}
@ -184,5 +187,5 @@ func run(configPath string) error {
signal.Notify(sigChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-sigChan
return srv.Close(ctx)
return tsrv.Close(ctx)
}