| 14 | ) |
| 15 | |
| 16 | func main() { |
| 17 | slog.Info("bytebase-action version " + args.Version + " built at commit " + args.Gitcommit) |
| 18 | ctx, cancel := context.WithCancel(context.Background()) |
| 19 | c := make(chan os.Signal, 1) |
| 20 | // Trigger graceful shutdown on SIGINT or SIGTERM. |
| 21 | // The default signal sent by the `kill` command is SIGTERM, |
| 22 | // which is taken as the graceful shutdown signal for many systems, eg., Kubernetes, Gunicorn. |
| 23 | signal.Notify(c, os.Interrupt, syscall.SIGTERM) |
| 24 | go func() { |
| 25 | sig := <-c |
| 26 | slog.Info(fmt.Sprintf("%s received.", sig.String())) |
| 27 | cancel() |
| 28 | }() |
| 29 | |
| 30 | w := world.NewWorld() |
| 31 | cmd := command.NewRootCommand(w) |
| 32 | |
| 33 | if err := cmd.ExecuteContext(ctx); err != nil { |
| 34 | slog.Error("failed to execute command", "error", fmt.Sprintf("%+v", err)) |
| 35 | os.Exit(1) |
| 36 | } |
| 37 | } |