-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvardis.go
61 lines (47 loc) · 1.04 KB
/
vardis.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
53
54
55
56
57
58
59
60
61
package main
import (
"os"
"strconv"
log "github.com/Sirupsen/logrus"
cache "github.com/valarpirai/vardis/cache"
"github.com/valarpirai/vardis/connection"
)
type VardisApp struct {
server *connection.Server
PORT uint16
}
func main() {
confgureApp()
log.Infoln("Starting Vardis server...")
arguments := os.Args
log.Debugln("Arguments...")
log.Debugln(arguments)
app := new(VardisApp)
if len(arguments) > 1 {
port, err := strconv.ParseUint(arguments[1], 10, 16)
if nil == err {
app.PORT = uint16(port)
}
}
if 0 == app.PORT {
app.PORT = 6379
}
NewApp(app)
}
func NewApp(app *VardisApp) {
cacheStore := cache.NewCache()
persistant := cache.NewStorage()
log.Info("Loading data from disk")
app.server = connection.NewServer(app.PORT, cacheStore, persistant)
go app.server.LoadFromDisk()
cacheStore.Exists("Test")
app.server.Start()
}
func confgureApp() {
log.SetFormatter(&log.JSONFormatter{})
log.SetFormatter(&log.TextFormatter{
FullTimestamp: true,
})
log.SetOutput(os.Stdout)
log.SetLevel(log.DebugLevel)
}