-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (41 loc) · 1.02 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
package main
import (
"flag"
"log"
"github.com/gincorp/gin/api"
"github.com/gincorp/gin/node"
)
var (
amqpURI *string
mode *string
redisURI *string
host *string
port *int
)
func init() {
amqpURI = flag.String("amqp", "amqp://guest:guest@localhost:5671/", "URI to pass messages via")
redisURI = flag.String("redis", "redis://localhost:6379/0", "URI of redis node")
mode = flag.String("mode", "job", "mode with which to run")
host = flag.String("host", "0.0.0.0", "In api mode; host to bind to")
port = flag.Int("port", 8080, "In api mode; port to listen on")
flag.Parse()
}
func main() {
log.Printf("Using %q", *amqpURI)
log.Printf("Running in %q mode", *mode)
switch *mode {
case "job", "master":
n := node.NewNode(*amqpURI, *redisURI, *mode)
if err := n.ConsumerLoop(); err != nil {
log.Fatal(err)
}
case "api":
a, err := api.NewAPI(*amqpURI, *redisURI, *host, *port)
if err != nil {
log.Fatal(err)
}
a.Start()
default:
log.Fatalf("Do not recognise mode '%q'", *mode)
}
}