forked from nats-io/nats-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnatsd.go
62 lines (47 loc) · 1.74 KB
/
gnatsd.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2012 Apcera Inc. All rights reserved.
package main
import (
"flag"
"log"
"net/http"
_ "net/http/pprof"
"github.com/apcera/gnatsd/server"
)
func main() {
// logging setup
server.LogSetup()
opts := server.Options{}
var debugAndTrace bool
// Parse flags
flag.IntVar(&opts.Port, "port", server.DEFAULT_PORT, "Port to listen on.")
flag.IntVar(&opts.Port, "p", server.DEFAULT_PORT, "Port to listen on.")
flag.StringVar(&opts.Host, "host", server.DEFAULT_HOST, "Network host to listen on.")
flag.StringVar(&opts.Host, "h", server.DEFAULT_HOST, "Network host to listen on.")
flag.BoolVar(&opts.Debug, "D", false, "Enable Debug logging.")
flag.BoolVar(&opts.Debug, "debug", false, "Enable Debug logging.")
flag.BoolVar(&opts.Trace, "V", false, "Enable Trace logging.")
flag.BoolVar(&opts.Trace, "trace", false, "Enable Trace logging.")
flag.BoolVar(&debugAndTrace, "DV", false, "Enable Debug and Trace logging.")
flag.StringVar(&opts.Username, "user", "", "Username required for connection.")
flag.StringVar(&opts.Password, "pass", "", "Password required for connection.")
flag.StringVar(&opts.Authorization, "auth", "", "Authorization token required for connection.")
flag.IntVar(&opts.HttpPort, "m", 0, "HTTP Port for /varz, /connz endpoints.")
flag.IntVar(&opts.HttpPort, "http_port", 0, "HTTP Port for /varz, /connz endpoints.")
flag.Parse()
if debugAndTrace {
opts.Trace, opts.Debug = true, true
}
// TBD: Parse config if given
// Create the server with appropriate options.
s := server.New(&opts)
// Start up the http server if needed.
if opts.HttpPort != 0 {
s.StartHTTPMonitoring()
}
// Profiler
go func() {
log.Println(http.ListenAndServe("localhost:6062", nil))
}()
// Wait for clients.
s.AcceptLoop()
}