blob: 00872aaea260c2dc3aa2cde3d35976e4ba4ce658 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package cmd
import (
"os"
"apjournal/config"
"apjournal/internal/server"
"log/slog"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
func init() {
rootCmd.AddCommand(startCmd)
}
var startCmd = &cobra.Command{
Use: "start",
Short: "Start data server",
Long: `Start data server`,
Run: func(cmd *cobra.Command, args []string) {
log := slog.New(slog.NewJSONHandler(os.Stdout, nil))
// load server configuration from server
log.Debug("Loading server configuration")
if viper.ConfigFileUsed() != "" {
log.Debug("Configuration file loaded", "section", "init",
"path", viper.ConfigFileUsed())
}
cfg := config.LoadConfig(viper.GetViper())
srv := server.NewServer(cfg, log)
// listen for new messages
log.Info("Listening for incoming events")
srv.Listen()
},
}
|