-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
58 lines (49 loc) · 1.15 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"context"
"fmt"
"os"
"packagelock/certs"
"packagelock/cmd"
"packagelock/config"
"packagelock/db"
"packagelock/handler"
"packagelock/logger"
"packagelock/server"
"packagelock/tracing"
"go.uber.org/fx"
"go.uber.org/fx/fxevent"
"go.uber.org/zap"
)
var AppVersion string // Version injected with ldflags
func main() {
app := fx.New(
fx.WithLogger(func(log *zap.Logger) fxevent.Logger {
return &fxevent.ZapLogger{Logger: log}
}),
// fx.NopLogger,
fx.Provide(
func() string {
return AppVersion
},
logger.NewLogger,
config.NewConfig,
),
certs.Module,
db.Module, // Include the database module
handler.Module, // Include the handlers module
server.Module, // Include the server module
cmd.Module, // Include the commands module
tracing.Module, // Include the tracing module
)
if err := app.Start(context.Background()); err != nil {
fmt.Println("Failed to start application:", err)
os.Exit(1)
}
// Wait for the application to be signaled to exit
<-app.Done()
if err := app.Stop(context.Background()); err != nil {
fmt.Println("Failed to stop application:", err)
os.Exit(1)
}
}