Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Version = "dev" Commit = "none" Date = "unknown" )
View Source
var RootCmd = &cobra.Command{ Use: "sandglass", Short: "Launch the server", Long: `Launch the server`, Run: func(cmd *cobra.Command, args []string) { conf := broker.Config{ Name: viper.GetString("name"), BindAddr: viper.GetString("bind_addr"), AdvertiseAddr: viper.GetString("advertise_addr"), DBPath: viper.GetString("db_path"), GossipPort: viper.GetString("gossip_port"), HTTPPort: viper.GetString("http_port"), GRPCPort: viper.GetString("grpc_port"), RaftPort: viper.GetString("raft_port"), InitialPeers: viper.GetStringSlice("initial_peers"), BootstrapRaft: viper.GetBool("bootstrap_raft"), OffsetReplicationFactor: viper.GetInt("offset_replication_factor"), } if viper.GetBool("verbose") { lvl := logy.DEBUG conf.LoggingLevel = &lvl } b, err := broker.New(&conf) if err != nil { log.Fatal(errors.Cause(err)) } if err := b.Bootstrap(); err != nil { log.Fatal(errors.Cause(err)) } if err := b.Join(conf.InitialPeers...); err != nil { log.Fatal(err) } logger := log.New(os.Stdout, conf.Name, log.LstdFlags) server := server.New(b, net.JoinHostPort(conf.BindAddr, conf.GRPCPort), net.JoinHostPort(conf.BindAddr, conf.HTTPPort), logy.NewWithLogger(logger, logy.INFO)) go func() { err := server.Start() if err != nil { log.Println(errors.Cause(err)) } }() fmt.Println(warningColor("WARNING: This code is a very early release, it contains bugs and should not be used in production environments.")) fmt.Println("") fmt.Println(infoColor("wait for it...")) err = b.WaitForIt() if err != nil { log.Fatal(err) } fmt.Println(sandglassColor(` ⏳ Sandglass started! Beware of the sandstorm. `)) gracefully.Timeout = 10 * time.Second gracefully.Shutdown() b.Debug("graceful shutdown") ctx := context.Background() b.Debug("shutting down http server") if err := server.Shutdown(ctx); err != nil { log.Println(errors.Cause(err)) } b.Debug("shutting down broker") if err := b.Stop(ctx); err != nil { log.Println(errors.Cause(err)) } fmt.Println(sandglassColor("⌛️ sandglass stopped!")) os.Exit(0) }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.