feat: deregister worker on close
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -4,9 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/orbis/internal/app"
|
||||
"github.com/joho/godotenv"
|
||||
@@ -21,22 +18,7 @@ func main() {
|
||||
|
||||
app := app.NewApp()
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
<-stop
|
||||
|
||||
app.Logger().Info("stop signal received: shutting down orbis")
|
||||
cancel()
|
||||
|
||||
// Start timer for hard stop
|
||||
time.Sleep(time.Second * 10)
|
||||
fmt.Println("orbis failed to stop in time, forced to hard cancel")
|
||||
os.Exit(1)
|
||||
}()
|
||||
|
||||
ctx := context.Background()
|
||||
if err := newRoot(app).ExecuteContext(ctx); err != nil {
|
||||
fmt.Printf("%s\n", err)
|
||||
os.Exit(1)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/orbis/internal/app"
|
||||
"git.front.kjuulh.io/kjuulh/orbis/internal/processes"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -14,13 +16,16 @@ func newRoot(app *app.App) *cobra.Command {
|
||||
Short: "Orbis is a data workflow scheduler for all your batch and real-time needs",
|
||||
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
ctx := cmd.Context()
|
||||
//ctx := cmd.Context()
|
||||
logger.Info("starting orbis")
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
return processes.
|
||||
NewApp(logger).
|
||||
Add(app.Scheduler()).
|
||||
Add(app.Worker()).
|
||||
WithCtrlC().
|
||||
Execute(ctx)
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user