| iomodo | c6abf5b | 2021-02-19 14:48:03 +0400 | [diff] [blame] | 1 | package commands |
| 2 | |
| 3 | import ( |
| 4 | "github.com/giolekva/pcloud/core/kg/log" |
| 5 | "github.com/giolekva/pcloud/core/kg/server" |
| 6 | "github.com/spf13/cobra" |
| 7 | ) |
| 8 | |
| 9 | // Command is an abstraction of the cobra Command |
| 10 | type Command = cobra.Command |
| 11 | |
| 12 | // Run function starts the application |
| 13 | func Run(args []string) error { |
| 14 | rootCmd.SetArgs(args) |
| 15 | return rootCmd.Execute() |
| 16 | } |
| 17 | |
| 18 | // rootCmd is a command to run the server. |
| iomodo | d32f9ee | 2021-02-21 21:28:50 +0400 | [diff] [blame] | 19 | var rootCmd = &Command{ |
| iomodo | c6abf5b | 2021-02-19 14:48:03 +0400 | [diff] [blame] | 20 | Use: "server", |
| 21 | Short: "An example of the basic server", |
| 22 | RunE: serverCmdF, |
| 23 | } |
| 24 | |
| 25 | func serverCmdF(command *cobra.Command, args []string) error { |
| 26 | config := &log.LoggerConfiguration{ |
| 27 | EnableConsole: true, |
| 28 | ConsoleJSON: true, |
| 29 | ConsoleLevel: "debug", |
| 30 | EnableFile: true, |
| 31 | FileJSON: true, |
| 32 | FileLevel: "debug", |
| 33 | FileLocation: "server.log", |
| 34 | } |
| 35 | logger := log.NewLogger(config) |
| iomodo | db170e1 | 2021-02-21 23:06:20 +0400 | [diff] [blame^] | 36 | grpcServer := server.NewGRPCServer(logger) |
| 37 | servers := server.New(logger) |
| 38 | servers.AddServers(grpcServer) |
| 39 | servers.Run() |
| iomodo | c6abf5b | 2021-02-19 14:48:03 +0400 | [diff] [blame] | 40 | |
| iomodo | c6abf5b | 2021-02-19 14:48:03 +0400 | [diff] [blame] | 41 | return nil |
| 42 | } |