blob: b5c92e23b2d9f9d7587e46ece047f85c4808970f [file] [log] [blame]
iomodoc6abf5b2021-02-19 14:48:03 +04001package commands
2
3import (
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
10type Command = cobra.Command
11
12// Run function starts the application
13func Run(args []string) error {
14 rootCmd.SetArgs(args)
15 return rootCmd.Execute()
16}
17
18// rootCmd is a command to run the server.
iomodod32f9ee2021-02-21 21:28:50 +040019var rootCmd = &Command{
iomodoc6abf5b2021-02-19 14:48:03 +040020 Use: "server",
21 Short: "An example of the basic server",
22 RunE: serverCmdF,
23}
24
25func 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)
iomododb170e12021-02-21 23:06:20 +040036 grpcServer := server.NewGRPCServer(logger)
37 servers := server.New(logger)
38 servers.AddServers(grpcServer)
39 servers.Run()
iomodoc6abf5b2021-02-19 14:48:03 +040040
iomodoc6abf5b2021-02-19 14:48:03 +040041 return nil
42}