forked from lastbackend/lastbackend
/
main.go
55 lines (42 loc) · 980 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
49
50
51
52
53
54
55
package daemon
import (
"fmt"
"github.com/deployithq/deployit/daemon/env"
"github.com/deployithq/deployit/drivers/localDB"
"github.com/deployithq/deployit/drivers/log"
"github.com/deployithq/deployit/drivers/docker"
"github.com/deployithq/deployit/utils"
"gopkg.in/urfave/cli.v2"
)
var Host string
var Port int
var Debug bool
func Init(c *cli.Context) error {
log := &log.Log{
Logger: log.New(),
}
paths := []string{
fmt.Sprintf("%s/apps", env.Default_root_path),
fmt.Sprintf("%s/tmp", env.Default_root_path),
}
if err := utils.CreateDirs(paths); err != nil {
log.Fatal(err)
return err
}
if Debug {
log.SetDebugLevel()
log.Debug("Debug mode enabled")
}
log.Info("Init local db")
ldb, _ := localDB.Init(fmt.Sprintf("%s/storage/", env.Default_root_path))
log.Info("Init daemon")
env := &env.Env{
LDB: ldb,
Log: log,
Containers: &docker.Containers{},
Host: Host,
}
log.Info("Context inited")
Route{}.Init(env)
return nil
}