-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
39 lines (33 loc) · 947 Bytes
/
app.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
package main
import (
"flag"
"github.com/just1689/playing-with-hpa/batch"
"github.com/just1689/playing-with-hpa/counter"
"github.com/just1689/playing-with-hpa/interest"
"github.com/sirupsen/logrus"
"os"
)
func main() {
flag.Parse()
logrus.Println("Starting...")
job := os.Getenv("job")
addr := os.Getenv("address")
nsqAddr := os.Getenv("nsqAddr")
if job == "batch" {
logrus.Println("> As batch...")
logrus.Println("Address: ", addr)
logrus.Println("NSQd address:", nsqAddr)
batch.UpdateBatchFromEnv()
batch.StartBatchServer(addr, nsqAddr)
} else if job == "worker" {
logrus.Println("> As worker...")
logrus.Println("NSQd address:", nsqAddr)
interest.StartPublisher(nsqAddr)
interest.StartInterestWorker(nsqAddr)
} else if job == "counter" {
logrus.Println("> As counter...")
logrus.Println("Address: ", addr)
counter.StartCounter(addr, nsqAddr)
}
logrus.Errorln("Nothing left to do. Shutting down")
}