-
Notifications
You must be signed in to change notification settings - Fork 15
/
main.go
68 lines (61 loc) · 1.57 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
package main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"github.com/icon-project/icon-bridge/cmd/e2etest/executor"
"github.com/icon-project/icon-bridge/common/log"
"github.com/pkg/errors"
_ "github.com/icon-project/icon-bridge/cmd/e2etest/chain/bsc"
_ "github.com/icon-project/icon-bridge/cmd/e2etest/chain/icon"
_ "github.com/icon-project/icon-bridge/cmd/e2etest/chain/near"
_ "github.com/icon-project/icon-bridge/cmd/e2etest/chain/snow"
)
func main() {
var cfgFile string
var maxTasks int
flag.StringVar(&cfgFile, "config", "", "e2e.config.json file")
flag.IntVar(&maxTasks, "maxTasks", 0, "maximum number of tasks to run")
flag.Parse()
cfg, err := executor.LoadConfig(cfgFile)
if err != nil {
log.Error(errors.Wrap(err, "loadConfig "))
return
}
l := executor.SetLogger(cfg)
l.Info("Initializing service")
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
defer func() {
signal.Stop(sigCh)
cancel()
}()
go func() {
select {
case <-sigCh: // first signal, cancel context
cancel()
case <-ctx.Done():
}
<-sigCh // second signal, hard exit
os.Exit(2)
}()
l.Info("Running Service")
ex, err := executor.New(l, cfg)
if err != nil {
log.Error(errors.Wrap(err, "executor.New "))
return
}
ex.Subscribe(ctx)
time.Sleep(5) // wait for subscription to start
err = ex.RunFlowTest(ctx, maxTasks)
if err != nil {
log.Errorf("Error Executing Flow Test %+v", err)
}
time.Sleep(time.Second * 2)
log.Warn("Exiting Service...")
}