|
@@ -0,0 +1,58 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+package cmd
|
|
|
+
|
|
|
+import (
|
|
|
+ "git.riomhaire.com/gremlin/jrpcserver/infrastructure/api/rpc"
|
|
|
+ "git.riomhaire.com/gremlin/jrpcserver/model"
|
|
|
+ "git.riomhaire.com/gremlin/jrpcserver/usecases"
|
|
|
+
|
|
|
+ "github.com/spf13/cobra"
|
|
|
+)
|
|
|
+
|
|
|
+var configPort int
|
|
|
+var configServicename string
|
|
|
+var configConsul string
|
|
|
+var configHost string
|
|
|
+
|
|
|
+
|
|
|
+var serveCmd = &cobra.Command{
|
|
|
+ Use: "serve",
|
|
|
+ Short: "Starts up a JSON RPC Service",
|
|
|
+ Run: func(cmd *cobra.Command, args []string) {
|
|
|
+
|
|
|
+ config := model.DefaultConfiguration{
|
|
|
+ Server: model.ServerConfig{
|
|
|
+ ServiceName: cmd.Flag("servicename").Value.String(),
|
|
|
+ BaseURI: "/api/v1/rpc",
|
|
|
+ Port: configPort,
|
|
|
+ Commands: usecases.InitializeCommands(),
|
|
|
+ Version: usecases.Version(),
|
|
|
+ Consul: configConsul,
|
|
|
+ Hostname: configHost,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ rpc.StartAPI(config)
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+func init() {
|
|
|
+ rootCmd.AddCommand(serveCmd)
|
|
|
+ serveCmd.Flags().IntVarP(&configPort, "port", "p", 3000, "Port to run on")
|
|
|
+ serveCmd.Flags().StringVarP(&configServicename, "servicename", "s", "git.riomhaire.com/gremlin/jrpcserver", "Name of service")
|
|
|
+ serveCmd.Flags().StringVarP(&configConsul, "consul", "c", "", "Consul host. Empty means dont use")
|
|
|
+ serveCmd.Flags().StringVarP(&configHost, "host", "b", "", "Interface/hostname to bind to")
|
|
|
+
|
|
|
+}
|