-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
44 lines (34 loc) · 849 Bytes
/
main.go
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
38
39
40
41
42
43
44
package main
import (
"fmt"
"os"
"github.com/ZeljkoBenovic/gombak/internal/app"
"github.com/ZeljkoBenovic/gombak/pkg/config"
"github.com/ZeljkoBenovic/gombak/pkg/logger"
"github.com/ZeljkoBenovic/gombak/pkg/service"
)
func main() {
conf := config.NewConfig()
log, err := logger.New(conf)
if err != nil {
fmt.Printf("could not create new logger: %s", err.Error())
os.Exit(1)
}
run := app.NewApp(conf, log).AppModeFactory()
srv, err := service.New(conf, []string{"run", "-c", conf.ConfigFilePath}, log)
if err != nil {
log.Info("could not init new service", "err", err)
os.Exit(1)
}
err, isService := srv.HandleServiceCLICommands(run)
if err != nil {
log.Error("service error", "err", err)
os.Exit(1)
}
if !isService {
if err = run(); err != nil {
log.Error("run error", "err", err)
os.Exit(1)
}
}
}