diff --git a/cmd/web/main.go b/cmd/web/main.go index 3482b2f..d4d64b3 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "errors" "fmt" + "github.com/mikestefanello/pagoda/pkg/tasks" "log" "net/http" "os" @@ -14,7 +15,6 @@ import ( "github.com/mikestefanello/pagoda/pkg/handlers" "github.com/mikestefanello/pagoda/pkg/services" - "github.com/mikestefanello/pagoda/pkg/tasks" ) func main() { @@ -31,6 +31,12 @@ func main() { log.Fatalf("failed to build the router: %v", err) } + // Register all task queues + tasks.Register(c) + + // Start the task runner to execute queued tasks + c.Tasks.Start(context.Background()) + // Start the server go func() { srv := http.Server{ @@ -57,12 +63,6 @@ func main() { } }() - // Register all task queues - tasks.Register(c) - - // Start the task runner to execute queued tasks - c.Tasks.Start(context.Background()) - // Wait for interrupt signal to gracefully shut down the server with a timeout of 10 seconds. quit := make(chan os.Signal, 1) signal.Notify(quit, os.Interrupt)