server

package
v0.0.0-...-f742aa8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package raza implements the commands to interact with the daemon.

Index

Constants

This section is empty.

Variables

View Source
var ServerCmd = cobra.Command{
	Use:   "server",
	Short: "Run the raza server",
}
View Source
var StartCmd = cobra.Command{
	Use:   "start",
	Short: "Start the raza server",
	Run: func(cmd *cobra.Command, args []string) {
		address, _ := cmd.Flags().GetString("address")
		lis, err := net.Listen("tcp", address)
		if err != nil {
			cmd.PrintErrf("Failed to listen: %v\n", err)
			return
		}

		s := grpc.NewServer()
		db, err := sql.Open("sqlite3", "./test.sqlite")
		if err != nil {
			log.Fatal().Err(err).Str("file", "./test.sqlite").
				Stack().Msg("failed to open database")
		}
		server := NewServer(db)
		defer server.Close()
		raza.RegisterRazaShellWrapperServer(s, server)
		raza.RegisterRazaQueryServer(s, server)
		raza.RegisterRazaUserServer(s, server)

		log.Info().Str("address", address).Msgf("Starting gRPC listener on %s", address)
		if err := s.Serve(lis); err != nil {
			cmd.PrintErrf("Failed to serve: %v\n", err)
			return
		}
	},
}

Functions

func NewServer

func NewServer(db_ *sql.DB) *server

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL