-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (42 loc) · 1.03 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 (
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
"time"
_ "net/http/pprof"
"github.com/GeekChomolungma/Chomolungma/config"
"github.com/GeekChomolungma/Chomolungma/db/mongoInc"
"github.com/GeekChomolungma/Chomolungma/engine"
"github.com/GeekChomolungma/Chomolungma/handler"
"github.com/GeekChomolungma/Chomolungma/logging/applogger"
)
func main() {
fmt.Println("CHOMOLUNGMA!")
// config server
config.Setup("./my.ini")
// setup the trade engine
engine.EngineBus = &engine.TradeEngine{
Cylinders: make(map[string]engine.Cylinder),
}
mongoInc.Init(config.MongoSetting.Uri)
engine.EngineBus.Load()
engine.EngineBus.Run()
// start http server
go handler.LocalServer()
go http.ListenAndServe(":6060", nil)
c := make(chan os.Signal, 5)
signal.Notify(c, os.Interrupt, os.Kill, syscall.SIGABRT, syscall.SIGTERM)
for {
select {
case sig := <-c:
applogger.Info("Capture a System Call: %s", sig.String())
engine.EngineBus.Stop()
return
default:
time.Sleep(time.Duration(3) * time.Second)
}
}
}