/
rustwizard
/
balda
Обзор
Документация
Войти
/
rustwizard
/
balda
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
cmd/root.go
36 строк
899 B
Rust Wizard
feat: graceful shutdown and HTTP server timeouts
03 июн 2026, 14:26
Не верифицирован
03 июн 2026, 14:26
ad6f600
Код
Авторство
О чём код?
package cmd import ( "context" "log/slog" "os" "os/signal" "syscall" "github.com/spf13/cobra" ) // rootCmd represents the base command when called without subcommands var rootCmd = &cobra.Command{ Use: "balda", Short: "Balda Game API Service", // Uncomment the following line if your bare application // has an action associated with it: // Run: func(cmd *cobra.Command, args []string) { }, } // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) defer stop() if err := rootCmd.ExecuteContext(ctx); err != nil { slog.Error("got an error when running Balda API service", slog.Any("error", err)) os.Exit(1) } } func init() { rootCmd.AddCommand(serverCmd) }