orbis/cmd/orbis/main.go
kjuulh fe02e0ac79
All checks were successful
continuous-integration/drone/push Build is passing
add orbis demo
2025-01-06 22:40:54 +01:00

45 lines
775 B
Go

package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"time"
"git.front.kjuulh.io/kjuulh/orbis/internal/app"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
if err != nil {
fmt.Printf("%s\n", err)
os.Exit(1)
}
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)
}()
if err := newRoot(app).ExecuteContext(ctx); err != nil {
fmt.Printf("%s\n", err)
os.Exit(1)
}
}