diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/server/main.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/server/main.go b/cmd/server/main.go index 702ca6e..1bd445c 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -33,6 +33,7 @@ func main() { dbCon = flag.String("db-con", "main.db", "Database string connection for given database type. Ref: https://gorm.io/docs/connecting_to_the_database.html") logLevel = flag.String("log-level", "error", "Log level: Choose either trace, debug, info, warning, error, fatal or panic") schedulerCount = flag.Uint("scheduler-count", 10, "How many workers are created to process media files") + cachePath = flag.String("cache-path", "", "Folder to store thumbnail image") // TODO: this will later be replaced by user specific root folder root = flag.String("root", "", "root folder for the whole application. All the workers will use it as working directory") @@ -112,8 +113,9 @@ func main() { // processors var ( - fileScanner = worker.NewFileScanner(*root, mediaRepository) - exifScanner = worker.NewEXIFScanner(mediaRepository) + fileScanner = worker.NewFileScanner(*root, mediaRepository) + exifScanner = worker.NewEXIFScanner(mediaRepository) + thumbnailScanner = worker.NewThumbnailScanner(*cachePath, mediaRepository) ) // worker @@ -129,12 +131,18 @@ func main() { scheduler, logrus.WithField("context", "exif scanner"), ) + thumbnailWorker = worker.NewWorkerFromBatchProcessor[*repository.Media]( + thumbnailScanner, + scheduler, + logrus.WithField("context", "thumbnail scanner"), + ) ) pool := worker.NewWorkerPool() pool.AddWorker("http server", serverWorker) pool.AddWorker("exif scanner", exifWorker) pool.AddWorker("file scanner", fileWorker) + pool.AddWorker("thumbnail scanner", thumbnailWorker) ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) defer stop() |