-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
37 lines (30 loc) · 888 Bytes
/
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
package main
import (
"net/http"
"runtime"
log "github.com/sirupsen/logrus"
"github.com/gorilla/websocket"
)
var Config *config = LoadConfig()
var Upgrader = websocket.Upgrader{
ReadBufferSize: Config.readBufferSize,
WriteBufferSize: Config.writeBufferSize,
CheckOrigin: func(r *http.Request) bool {
return true
},
}
func main() {
log.WithFields(log.Fields{
"version": VERSION,
"port": Config.port,
"cores": runtime.NumCPU()}).Info("Initializing Philotic Network")
log.WithFields(log.Fields{
"read-buffer-size": Config.readBufferSize,
"write-buffer-size": Config.writeBufferSize,
"max-connections": Config.maxConnections}).Debug("Configuration options:")
h := NewHive()
http.HandleFunc("/", h.ServeNewConnection)
err := http.ListenAndServe(":" + Config.port, nil); if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}