forked from boyska/circolog
Merge branch '5-socketpaths'
This commit is contained in:
commit
db33746f26
2 changed files with 8 additions and 8 deletions
|
@ -54,8 +54,8 @@ func (b *BoolAuto) Set(s string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
addr := flag.String("addr", "localhost:9080", "http service address")
|
queryAddr := flag.String("addr", "", "http service address")
|
||||||
querySocket := flag.String("socket", "", "Path to a unix domain socket for the HTTP server")
|
querySocket := flag.String("socket", "/tmp/circologd-query.sock", "Path to a unix domain socket for the HTTP server")
|
||||||
backlogLimit := flag.Int("n", -1, "Limit the backlog length, defaults to no limit (-1)")
|
backlogLimit := flag.Int("n", -1, "Limit the backlog length, defaults to no limit (-1)")
|
||||||
var format formatter.Format
|
var format formatter.Format
|
||||||
format = formatter.FormatSyslog
|
format = formatter.FormatSyslog
|
||||||
|
@ -75,7 +75,7 @@ func main() {
|
||||||
signal.Notify(interrupt, os.Interrupt)
|
signal.Notify(interrupt, os.Interrupt)
|
||||||
var d *websocket.Dialer
|
var d *websocket.Dialer
|
||||||
u := url.URL{Scheme: "ws",
|
u := url.URL{Scheme: "ws",
|
||||||
Host: *addr, // ignored in case of -socket; see the Dialer below
|
Host: *queryAddr, // ignored in case of -socket; see the Dialer below
|
||||||
Path: "/ws",
|
Path: "/ws",
|
||||||
}
|
}
|
||||||
q := u.Query()
|
q := u.Query()
|
||||||
|
@ -84,7 +84,7 @@ func main() {
|
||||||
q.Set("l", strconv.Itoa(*backlogLimit))
|
q.Set("l", strconv.Itoa(*backlogLimit))
|
||||||
}
|
}
|
||||||
u.RawQuery = q.Encode()
|
u.RawQuery = q.Encode()
|
||||||
if *querySocket != "" {
|
if *queryAddr == "" {
|
||||||
d = &websocket.Dialer{
|
d = &websocket.Dialer{
|
||||||
NetDial: func(network, addr string) (net.Conn, error) {
|
NetDial: func(network, addr string) (net.Conn, error) {
|
||||||
return net.Dial("unix", *querySocket)
|
return net.Dial("unix", *querySocket)
|
||||||
|
@ -95,7 +95,7 @@ func main() {
|
||||||
log.Printf("connecting to %s", *querySocket)
|
log.Printf("connecting to %s", *querySocket)
|
||||||
} else {
|
} else {
|
||||||
d = websocket.DefaultDialer
|
d = websocket.DefaultDialer
|
||||||
log.Printf("connecting to %s", *addr)
|
log.Printf("connecting to %s", *queryAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
c, _, err := d.Dial(u.String(), nil)
|
c, _, err := d.Dial(u.String(), nil)
|
||||||
|
|
|
@ -38,8 +38,8 @@ func main() {
|
||||||
// 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")
|
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", "", "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!")
|
querySocket := flag.String("query-socket", "/tmp/circologd-query.sock", "Path to a unix domain socket for the HTTP server; recommended for security reasons!")
|
||||||
ctlSocket := flag.String("ctl-socket", "/tmp/circologd-ctl.sock", "Path to a unix domain socket for the control server; leave empty to disable")
|
ctlSocket := flag.String("ctl-socket", "/tmp/circologd-ctl.sock", "Path to a unix domain socket for the control server; leave empty to disable")
|
||||||
flag.Var(&logFmt, "log-fmt", "Log messages format. If not set, defaults to automatic choice. Allowed values: rfc3164, rfc5424, auto.")
|
flag.Var(&logFmt, "log-fmt", "Log messages format. If not set, defaults to automatic choice. Allowed values: rfc3164, rfc5424, auto.")
|
||||||
verbose := flag.Bool("verbose", false, "Print more output executing the daemon")
|
verbose := flag.Bool("verbose", false, "Print more output executing the daemon")
|
||||||
|
@ -89,7 +89,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
httpQueryServer := http.Server{Handler: setupHTTP(hub)}
|
httpQueryServer := http.Server{Handler: setupHTTP(hub)}
|
||||||
if *querySocket != "" {
|
if *queryAddr == "" {
|
||||||
fmt.Printf("Binding address `%s` [http]\n", *querySocket)
|
fmt.Printf("Binding address `%s` [http]\n", *querySocket)
|
||||||
unixListener, err := net.Listen("unix", *querySocket)
|
unixListener, err := net.Listen("unix", *querySocket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue