HTTP unix domain socket
This commit is contained in:
parent
8568280dd1
commit
71763cf8b1
1 changed files with 14 additions and 2 deletions
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ func main() {
|
||||||
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")
|
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")
|
queryAddr := flag.String("query-addr", "127.0.0.1:9080", "Address:port where to bind the query service")
|
||||||
|
querySocket := flag.String("query-socket", "", "Path to a unix domain socket for the HTTP server; recommended for security reasons!")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
hub := circolog.NewHub(*bufsize)
|
hub := circolog.NewHub(*bufsize)
|
||||||
|
@ -45,7 +47,17 @@ func main() {
|
||||||
go hub.Run()
|
go hub.Run()
|
||||||
|
|
||||||
setupHttp(hub)
|
setupHttp(hub)
|
||||||
fmt.Printf("Binding address `%s` [http]\n", *queryAddr)
|
if *querySocket != "" {
|
||||||
http.ListenAndServe(*queryAddr, nil)
|
fmt.Printf("Binding address `%s` [http]\n", *querySocket)
|
||||||
|
unixListener, err := net.Listen("unix", *querySocket)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, "Error binding HTTP unix domain socket", err)
|
||||||
|
}
|
||||||
|
defer os.Remove(*querySocket)
|
||||||
|
http.Serve(unixListener, nil)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Binding address `%s` [http]\n", *queryAddr)
|
||||||
|
http.ListenAndServe(*queryAddr, nil)
|
||||||
|
}
|
||||||
server.Wait()
|
server.Wait()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue