forked from donovanhide/superfastmatch
/
superfastmatch.go
44 lines (42 loc) · 1.09 KB
/
superfastmatch.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
package main
import (
"github.com/donovanhide/superfastmatch/api"
"github.com/donovanhide/superfastmatch/client"
"github.com/donovanhide/superfastmatch/posting"
"github.com/donovanhide/superfastmatch/queue"
"github.com/donovanhide/superfastmatch/registry"
"github.com/golang/glog"
"net/http"
_ "net/http/pprof"
"os"
"os/signal"
"runtime"
)
func main() {
if len(os.Args) >= 2 && os.Args[1] == "client" {
client.Run(os.Args[2:])
return
}
runtime.GOMAXPROCS(runtime.NumCPU())
registry := registry.NewRegistry()
registry.Open()
defer registry.Close()
glog.Infof("Started in %v mode with Hash Width: %v and Window Size: %v", registry.Mode, registry.HashWidth, registry.WindowSize)
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt)
go http.ListenAndServe("localhost:6060", nil)
switch registry.Mode {
case "posting":
posting.Serve(registry)
case "api":
go queue.Start(registry)
go api.MonitorFeeds(registry)
go api.Serve(registry)
case "standalone":
posting.Serve(registry)
go queue.Start(registry)
go api.MonitorFeeds(registry)
go api.Serve(registry)
}
<-sig
}