-
Notifications
You must be signed in to change notification settings - Fork 76
/
main.go
42 lines (31 loc) · 882 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
//go:build linux || darwin
package main
import (
"fmt"
"log"
"os"
"github.com/alash3al/redix/internals/config"
"github.com/alash3al/redix/internals/datastore/contract"
"github.com/alash3al/redix/internals/redis"
_ "github.com/alash3al/redix/internals/datastore/engines/filesystem"
_ "github.com/alash3al/redix/internals/datastore/engines/postgresql"
)
var (
cfg *config.Config
)
func main() {
if len(os.Args) < 2 {
log.Fatal("you must specify the configuration file as an argument")
}
var err error
fmt.Println("=> loading the configs ...")
cfg, err = config.Unmarshal(os.Args[1])
if err != nil {
log.Fatal("unable to load the config file due to: ", err.Error())
}
db, err := contract.Open(cfg.Engine.Driver, cfg.Engine.DSN)
if err != nil {
log.Fatal("failed to open database connection due to: ", err.Error())
}
redis.ListenAndServe(cfg, db)
}