summaryrefslogtreecommitdiff
path: root/main.go
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 4 insertions, 8 deletions
diff --git a/main.go b/main.go
index bb3e208..d41baa9 100644
--- a/main.go
+++ b/main.go
@@ -86,13 +86,11 @@ func main() {
default:
}
- processSemaphore := make(chan struct{}, cfg.MaxProcessThreads)
- queueSemaphore := make(chan struct{}, cfg.MaxPreProcessThreads)
+ semaphore := make(chan struct{}, cfg.MaxConcurrentJobs)
var wg sync.WaitGroup
wg.Add(len(files))
for i, file := range files {
- queueSemaphore <- struct{}{}
go func(index int, inputName string) {
outputName := conv.DeductOutputPath(inputName)
fileLogger := generalLogger.With(slog.String("input_path", inputName), slog.String("output_path", outputName), slog.Int("file_index", index))
@@ -100,8 +98,9 @@ func main() {
threadSigTermChannel := make(chan os.Signal, 1)
signal.Notify(threadSigTermChannel, os.Interrupt, syscall.SIGTERM)
- defer func() { <-queueSemaphore; wg.Done() }()
-
+ defer func() { <-semaphore }()
+ defer wg.Done()
+ semaphore <- struct{}{}
select {
case <-threadSigTermChannel:
fileLogger.Info("exiting due to termination signal")
@@ -129,9 +128,6 @@ func main() {
}
}
- processSemaphore <- struct{}{}
- defer func() { <-processSemaphore }()
-
fileLogger.Info("start to process file", slog.String("input_hash", inputMetadata.Hash), slog.String("original_input_hash", originalInputHash))
reader, err := inputClient.GetReader(inputName)
if err != nil {