Merge remote-tracking branch 'blallo/master'

This commit is contained in:
boyska 2018-08-22 23:44:54 +02:00
commit 3bf88506be

11
main.go
View file

@ -38,6 +38,8 @@ func main() {
syslogSocketPath := flag.String("syslogd-socket", "", "The socket to listen to syslog addresses") syslogSocketPath := flag.String("syslogd-socket", "", "The socket to listen to syslog addresses")
// dumpSocketPath := flag.String("dump-socket", "/run/buffer.sock", "The socket that user will connect to in order to receive logs") // dumpSocketPath := flag.String("dump-socket", "/run/buffer.sock", "The socket that user will connect to in order to receive logs")
bufsize := flag.Int("buffer-size", 1000, "Number of messages to keep") bufsize := flag.Int("buffer-size", 1000, "Number of messages to keep")
syslogAddr := flag.String("syslog-addr", "127.0.0.1:9514", "Address:port where to listen for syslog messages")
queryAddr := flag.String("query-addr", "127.0.0.1:9080", "Address:port where to bind the query service")
flag.Parse() flag.Parse()
channel := make(chan format.LogParts) channel := make(chan format.LogParts)
@ -50,17 +52,16 @@ func main() {
server.ListenUnixgram(*syslogSocketPath) server.ListenUnixgram(*syslogSocketPath)
fmt.Printf("Binding socket `%s` [syslog]\n", *syslogSocketPath) fmt.Printf("Binding socket `%s` [syslog]\n", *syslogSocketPath)
} else { } else {
addr := "127.0.0.1:9514" fmt.Printf("Binding address `%s` [syslog]\n", *syslogAddr)
fmt.Printf("Binding address `%s` [syslog]\n", addr) server.ListenUDP(*syslogAddr)
server.ListenUDP(addr)
} }
circbuf = ring.New(*bufsize) circbuf = ring.New(*bufsize)
server.Boot() server.Boot()
go syslogdHandler(channel) go syslogdHandler(channel)
http.HandleFunc("/", httpHandler) http.HandleFunc("/", httpHandler)
fmt.Printf("Binding address `%s` [http]\n", ":9080") fmt.Printf("Binding address `%s` [http]\n", *queryAddr)
http.ListenAndServe(":9080", nil) http.ListenAndServe(*queryAddr, nil)
server.Wait() server.Wait()
} }