Start task runner before web server.
This commit is contained in:
parent
d2d8c02a2f
commit
a7006b3997
1 changed files with 7 additions and 7 deletions
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/mikestefanello/pagoda/pkg/tasks"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -14,7 +15,6 @@ import (
|
||||||
|
|
||||||
"github.com/mikestefanello/pagoda/pkg/handlers"
|
"github.com/mikestefanello/pagoda/pkg/handlers"
|
||||||
"github.com/mikestefanello/pagoda/pkg/services"
|
"github.com/mikestefanello/pagoda/pkg/services"
|
||||||
"github.com/mikestefanello/pagoda/pkg/tasks"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -31,6 +31,12 @@ func main() {
|
||||||
log.Fatalf("failed to build the router: %v", err)
|
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
|
// Start the server
|
||||||
go func() {
|
go func() {
|
||||||
srv := http.Server{
|
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.
|
// Wait for interrupt signal to gracefully shut down the server with a timeout of 10 seconds.
|
||||||
quit := make(chan os.Signal, 1)
|
quit := make(chan os.Signal, 1)
|
||||||
signal.Notify(quit, os.Interrupt)
|
signal.Notify(quit, os.Interrupt)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue