-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (34 loc) · 1.05 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
package main
import (
"os"
"os/signal"
"path/filepath"
"syscall"
"github.com/CefBoud/monkafka/broker"
log "github.com/CefBoud/monkafka/logging"
"github.com/CefBoud/monkafka/types"
)
var config = types.Configuration{
LogDir: filepath.Join(os.TempDir(), "MonKafka"),
BrokerHost: "localhost",
BrokerPort: 9092,
FlushIntervalMs: 5000,
LogRetentionCheckIntervalMs: 1000 * 30, // 30 sec //5 * 60 * 1000, // 5 min
LogRetentionMs: 3 * 60 * 60 * 1000, // 3h //604800000 (7 days)
LogSegmentSizeBytes: 104857600 * 5, // 500 MiB
LogSegmentMs: 1800000, // 30 min
}
func main() {
// TODO: config from args / env
broker := broker.NewBroker(config)
// log.SetLogLevel(log.DEBUG)
signalChannel := make(chan os.Signal, 1)
signal.Notify(signalChannel, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-signalChannel
log.Info("\nReceived signal: %s. Shutting down...\n", sig)
broker.Shutdown()
os.Exit(0)
}()
broker.Startup()
}