forked from c4pt0r/pcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (42 loc) · 1.18 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
package main
import (
"flag"
"net/http"
"github.com/ngaut/log"
redis "gopkg.in/redis.v6"
)
var (
flagLoadRelationship = flag.String("load-rel", "", "")
flagLoadLikes = flag.String("load-likes", "", "")
flagRedisAddr = flag.String("redis-addr", "127.0.0.1:6379", "")
flagStorePath = flag.String("store", "localstore", "")
flagNicknames = flag.String("nicknames", "nicknames", "")
flagSkip = flag.Int("load-from", 0, "")
logLevel = flag.String("log-level", "info", "")
)
var nicknameMap = make(map[uint64]string)
func main() {
flag.Parse()
log.SetLevelByString(*logLevel)
if len(*flagLoadRelationship) > 0 {
loadRelationship(*flagStorePath, *flagLoadRelationship, *flagSkip)
return
}
if len(*flagLoadLikes) > 0 {
loadLikes(*flagRedisAddr, *flagStorePath, *flagLoadLikes, *flagSkip)
return
}
// launch server
loadNickname(*flagNicknames)
hdlr := LikeHandler{
localStore: newLevelDBStore(*flagStorePath),
redisStore: redis.NewClient(&redis.Options{
Addr: *flagRedisAddr,
}),
}
log.Info("Listening http://0.0.0.0:8080/")
err := http.ListenAndServe("0.0.0.0:8080", hdlr)
if err != nil {
log.Fatal(err)
}
}