-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
66 lines (52 loc) · 2.13 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"github.com/carsonsx/nathttpd/conf"
"flag"
"fmt"
"os"
"github.com/carsonsx/nathttpd/server"
)
var usageStr = `
Usage: nathttpd [options]
Server Options:
-u, --url <url> Message queue connnection url (default: amqp://0.0.0.0:5672)
--request_queue <name> Http request queue name (default: nat_http_request)
--response_queue <name> Http response queue name (default: nat_http_response)
Logging Options:
-l, --log <file> File to redirect log output
-T, --logtime Timestamp log entries (default: true)
-s, --syslog Enable syslog as log method
-r, --remote_syslog <addr> Syslog server addr (udp://localhost:514)
-D, --debug Enable debugging output
-V, --trace Trace the raw protocol
-DV Debug and trace
Authorization Options:
--user <user> User required for connections
--pass <password> Password required for connections
Common Options:
-h, --help Show this message
-v, --version Show version
`
// usage will print out the flag options for the server.
func usage() {
fmt.Printf("%s\n", usageStr)
os.Exit(0)
}
func main() {
var showVersion bool
flag.StringVar(&conf.MQConf.Url, "url", conf.MQConf.Url, "Http message queue url.")
flag.StringVar(&conf.MQConf.Url, "u", conf.MQConf.Url, "Http message queue url.")
flag.StringVar(&conf.MQConf.ReqQueue, "request_queue", conf.MQConf.ReqQueue, "Http request message queue name.")
flag.StringVar(&conf.MQConf.ResQueue, "response_queue", conf.MQConf.ResQueue, "Http respnse message queue name.")
flag.BoolVar(&showVersion, "version", false, "Print version information.")
flag.BoolVar(&showVersion, "v", false, "Print version information.")
flag.Usage = usage
flag.Parse()
// Show version and exit
if showVersion {
server.PrintServerAndExit()
}
server.CreateRabbitQueue(conf.MQConf.Url, conf.MQConf.ReqQueue)
server.CreateRabbitQueue(conf.MQConf.Url, conf.MQConf.ResQueue)
server.Run()
}