diff --git a/cmd/media_repo/main.go b/cmd/media_repo/main.go index 5b82f83f3e88c42c57822e68bd7d7208249af4d9..ee80e9df453ea682b48487ba76781efb1f3c250b 100644 --- a/cmd/media_repo/main.go +++ b/cmd/media_repo/main.go @@ -79,10 +79,10 @@ func main() { // Set up a listener for SIGINT stop := make(chan os.Signal) - defer close(stop) signal.Notify(stop, os.Interrupt, os.Kill) selfStop := false go func() { + defer close(stop) <-stop selfStop = true diff --git a/controllers/data_controller/import_controller.go b/controllers/data_controller/import_controller.go index be6db5a16237d9986b2cde6a89d8ebec1fb26cc1..05003e03f6079177f684818e18138ff1d184166a 100644 --- a/controllers/data_controller/import_controller.go +++ b/controllers/data_controller/import_controller.go @@ -54,7 +54,6 @@ func StartImport(data io.Reader, ctx rcontext.RequestContext) (*types.Background // Start the import and send it its first update updateChan := make(chan *importUpdate) - defer close(updateChan) go doImport(updateChan, task.ID, importId, ctx) openImports.Store(importId, updateChan) updateChan <- &importUpdate{stop: false, fileMap: results} @@ -131,6 +130,8 @@ func processArchive(data io.Reader) (map[string]*bytes.Buffer, error) { } func doImport(updateChannel chan *importUpdate, taskId int, importId string, ctx rcontext.RequestContext) { + defer close(updateChannel) + // Use a new context in the goroutine ctx.Context = context.Background()