- Add edge node unit tests and transport package - Add node test client and related artifacts - Update bootstrap, node, and config modules - Add proto generated files - Update Makefile and configuration files
46 lines
878 B
Go
46 lines
878 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
"go.uber.org/fx"
|
|
|
|
"iop/apps/edge/internal/bootstrap"
|
|
"iop/packages/config"
|
|
)
|
|
|
|
var cfgFile string
|
|
|
|
func main() {
|
|
if err := rootCmd().Execute(); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func rootCmd() *cobra.Command {
|
|
root := &cobra.Command{
|
|
Use: "iop-edge",
|
|
Short: "IOP Edge — node gateway server",
|
|
}
|
|
root.PersistentFlags().StringVarP(&cfgFile, "config", "c", "configs/edge.yaml", "config file path")
|
|
root.AddCommand(serveCmd())
|
|
return root
|
|
}
|
|
|
|
func serveCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "serve",
|
|
Short: "Start the edge server",
|
|
RunE: func(_ *cobra.Command, _ []string) error {
|
|
cfg, err := config.LoadEdge(cfgFile)
|
|
if err != nil {
|
|
return fmt.Errorf("load config: %w", err)
|
|
}
|
|
fx.New(bootstrap.Module(cfg)).Run()
|
|
return nil
|
|
},
|
|
}
|
|
}
|