/
waved.go
68 lines (58 loc) · 1.34 KB
/
waved.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
62
63
64
65
66
67
68
package waved
import (
"fmt"
"os"
"time"
"github.com/immesys/wave/consts"
"github.com/immesys/wave/eapi"
"github.com/immesys/wave/iapi"
"github.com/immesys/wave/localdb/lls"
"github.com/immesys/wave/localdb/poc"
"github.com/immesys/wave/storage/overlay"
"github.com/urfave/cli"
)
const VersionFlag = "0.4.1"
func Main(args []string) {
app := cli.NewApp()
app.Name = "waved"
app.Usage = "Run a WAVE daemon"
app.Action = action
app.Version = VersionFlag
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config",
Value: "/etc/wave/wave.toml",
},
}
app.Run(args)
}
func action(c *cli.Context) error {
conf, err := ParseConfig(c.String("config"))
if err != nil {
fmt.Printf("could not parse config file: %v", err)
os.Exit(1)
}
MainWithConfig(conf)
return nil
}
func MainWithConfig(c *Configuration) {
llsdb, err := lls.NewLowLevelStorage(c.Database)
if err != nil {
fmt.Printf("state database error: %v\n", err)
os.Exit(1)
}
si, err := overlay.NewOverlay(c.Storage)
if err != nil {
fmt.Printf("storage overlay error: %v\n", err)
os.Exit(1)
}
consts.DefaultToUnrevoked = c.DefaultToUnrevoked
iapi.InjectStorageInterface(si)
ws := poc.NewPOC(llsdb)
api := eapi.NewEAPI(ws)
api.StartServer(c.ListenIP, c.HTTPListenIP)
fmt.Printf("server started on %s\n", c.ListenIP)
for {
time.Sleep(10 * time.Second)
}
}