-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.go
75 lines (59 loc) · 1.54 KB
/
init.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
69
70
71
72
73
74
75
package main
import (
"os"
"path"
"strings"
)
var (
// ExecutionPath will be set on runtime to determine the location of the binary
ExecutionPath string
// LogDirPath is the path of the log directory
LogDirPath string
// MyNodePath specifies the path where the node repository
// (containing data and configuration) of the default node
// used by the application is stored
MyNodePath string
// MyNodePath specifies the path where the node repository
// (containing data and configuration) of the default node
// used by the application is stored
MyUserConfPath string
// MyNode provides a global Node instance of user's own node
MyNode *Node
// MyUser provides a global instance of user running this agora node
MyUser *User
)
func InitPaths() error {
ex, err := os.Executable()
if err != nil {
return err
}
ExecutionPath = path.Dir(ex)
LogDirPath = ExecutionPath + "/data"
MyNodePath = ExecutionPath + "/data/MyNode"
MyUserConfPath = ExecutionPath + "/data/me.json"
return nil
}
func init() {
err := InitPaths()
if err != nil {
panic(err)
}
// Initializes flags and make flags available globally via
// opts variable
InitFlags()
InitLogger()
// Need to increse limit for number of filedescriptors to
// avoid running out of those due to a lot of sockets
err = checkAndSetUlimit()
if err != nil {
panic(err)
}
// Set Curator module
if strings.ToLower(opts.Curator) == "none" {
Info.Println("Using DummyCurator")
MyCurator = &DummyCurator{}
} else {
Info.Println("Using MLCurator")
MyCurator = &MLCurator{}
}
}