-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
48 lines (37 loc) · 1016 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
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"github.com/BenJoyenConseil/bluckdb/api"
"github.com/BenJoyenConseil/bluckdb/bluckstore"
"github.com/kataras/iris"
"github.com/labstack/gommon/log"
"os"
"os/signal"
)
const (
logHeader = "${time_rfc3339}\t[BluckServer]\t${level}\t"
logPrefix = `${time_rfc3339}\t${level}\t${prefix}\t${short_file}\t${line}`
)
func main() {
var port string
flag.StringVar(&port, "p", "2233", "Specify the host port to bind the database")
flag.Parse()
log.EnableColor()
log.SetHeader(logHeader)
log.SetPrefix(logPrefix)
store := bluckstore.NewMmapMultiStore()
go func() {
sigchan := make(chan os.Signal, 10)
signal.Notify(sigchan, os.Interrupt, os.Kill)
<-sigchan
log.Error("Program killed !")
store.Close()
os.Exit(0)
}()
log.Info("Launch the server to listen on port " + port)
log.Info("Press ^Ĉ to exit")
api := api.AppendIrisHandlers(store)
api.Set(iris.OptionDisableBanner(true))
api.Set(iris.OptionDisablePathCorrection(true))
api.Listen(":" + port)
}