From 9a87004f31224f75b966aea91689e95248b4f839 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 31 Jan 2024 21:28:31 -0500 Subject: [PATCH] fix: need to add lifecycle hook to start tusWorker --- storage/storage.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/storage/storage.go b/storage/storage.go index 8c0d3ef..10f15e9 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -74,14 +74,23 @@ func (s *StorageServiceDefault) Start() error { return nil } -func NewStorageService(params StorageServiceParams) *StorageServiceDefault { - return &StorageServiceDefault{ +func NewStorageService(lc fx.Lifecycle, params StorageServiceParams) *StorageServiceDefault { + ss := &StorageServiceDefault{ config: params.Config, logger: params.Logger, db: params.Db, accounts: params.Accounts, cron: params.Cron, } + + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + go ss.tusWorker() + return nil + }, + }) + + return ss } func (s StorageServiceDefault) PutFileSmall(file io.ReadSeeker, bucket string, generateProof bool) ([]byte, error) {