-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
57 lines (48 loc) · 1.16 KB
/
main.go
File metadata and controls
57 lines (48 loc) · 1.16 KB
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
package main
import (
"context"
"fmt"
"log-processor/config"
"log-processor/processor"
"os"
"os/signal"
"syscall"
"github.com/charmbracelet/log"
streamdal "github.com/streamdal/streamdal/sdks/go" // Import Streamdal SDK
)
func main() {
cfg := config.New()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Setup Streamdal client
streamdalClient, err := streamdal.New(&streamdal.Config{
ServerURL: cfg.StreamdalServer,
ServerToken: cfg.StreamdalToken,
ServiceName: cfg.StreamdalServiceName,
ShutdownCtx: ctx,
})
if err != nil {
log.Fatalf("Failed to initialize Streamdal client: %v", err)
}
// Setup log processor
p, err := processor.New(&processor.Config{
LogStashAddr: cfg.LogstashAddr,
ListenAddr: cfg.ListenAddr,
Streamdal: streamdalClient,
ShutdownCtx: ctx,
})
if err != nil {
log.Fatalf("Failed to initialize log processor: %v", err)
}
// Capture SIGINT and SIGTERM to trigger a shutdown.
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT)
signal.Notify(c, syscall.SIGTERM)
go func() {
<-c
cancel()
}()
// Start processing logs
fmt.Println(p.LogStashAddr)
p.ListenForLogs()
}