Start task runner before web server.
This commit is contained in:
parent
f8192d3ad6
commit
4e5c5127e8
1 changed files with 7 additions and 7 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue