-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
84 lines (69 loc) · 1.89 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main
import (
"context"
"fmt"
"log"
"os"
"path"
"path/filepath"
"sync"
"github.com/jessevdk/go-flags"
"github.com/netsec-ethz/bootstrapper"
"github.com/netsys-lab/scion-host/environment"
)
type Options struct {
// Example of verbosity with level
Verbose []bool `short:"v" long:"verbose" description:"Verbose output"`
// Example of optional value
Bootstrap string `short:"b" long:"bootstrap" description:"Bootstrapping URL" optional:"yes"`
}
var opts Options
func main() {
_, err := flags.Parse(&opts)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
endhostEnv := environment.EndhostEnv
fmt.Println("Got env")
fmt.Println(endhostEnv)
endhostEnv.BootstrappingUrl = opts.Bootstrap
// TODO: Proper error handling, do not fatal in here...
endhostEnv.Install()
code := bootstrapper.Run(filepath.Join(endhostEnv.ConfigPath, "bootstrapper.toml"), endhostEnv.ConfigPath)
if code != 0 {
log.Fatal("Bootstrapping failed")
}
// TODO: Supervise processes, ensure everything is running, restart in case something crashes
// TODO: Write to logs and give helpful output
/*
dispatcherCmd := exec.Command(endhostEnv.DispatcherBinaryPath, "--config", filepath.Join(endhostEnv.DispatcherConfigPath, "dispatcher.toml"))
dispatcherCmd.Stderr = os.Stderr
dispatcherCmd.Stdout = os.Stdout
daemonCmd := exec.Command(endhostEnv.DaemonBinaryPath, "--config", filepath.Join(endhostEnv.DaemonConfigPath, "sciond.toml"))
daemonCmd.Stderr = os.Stderr
daemonCmd.Stdout = os.Stdout
*/
var wg sync.WaitGroup
/*wg.Add(1)
go func() {
defer wg.Done()
err := dispatcherCmd.Start()
if err != nil {
log.Fatal(err)
}
err = dispatcherCmd.Wait()
if err != nil {
log.Fatal(err)
}
}()*/
wg.Add(1)
go func() {
defer wg.Done()
err := runDaemon(context.Background(), path.Join(endhostEnv.DaemonConfigPath, "sciond.toml"))
if err != nil {
log.Fatal(err)
}
}()
wg.Wait()
}