This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/orbis/internal/app"
|
||||
"github.com/joho/godotenv"
|
||||
@@ -17,7 +21,23 @@ func main() {
|
||||
|
||||
app := app.NewApp()
|
||||
|
||||
if err := newRoot(app).Execute(); err != nil {
|
||||
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)
|
||||
}()
|
||||
|
||||
if err := newRoot(app).ExecuteContext(ctx); err != nil {
|
||||
fmt.Printf("%s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
Reference in New Issue
Block a user