-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
82 lines (70 loc) · 1.65 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
package main
import (
"crypto/tls"
"flag"
"github.com/cadence-workflow/starlark-worker/cad"
"github.com/cadence-workflow/starlark-worker/cadstar"
"github.com/cadence-workflow/starlark-worker/plugin"
"github.com/uber-go/tally"
"go.uber.org/cadence/worker"
"go.uber.org/cadence/workflow"
"go.uber.org/zap"
"net/http"
"os"
"os/signal"
"syscall"
)
func init() {
http.DefaultClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
}
}
func main() {
flags := flag.NewFlagSet(os.Args[0], flag.ExitOnError)
opt := _Options{}
opt.BindFlags(flags)
if err := flags.Parse(os.Args[1:]); err != nil {
panic(err)
}
z := zap.NewDevelopmentConfig()
z.Level = zap.NewAtomicLevelAt(zap.InfoLevel)
logger, err := z.Build()
if err != nil {
panic(err)
}
logger.Info("Options", zap.Any("Options", opt))
cadInterface := cad.NewInterface(opt.CadenceURL)
cadWorker := worker.New(
cadInterface,
opt.CadenceDomain,
opt.CadenceTaskList,
worker.Options{
MetricsScope: tally.NoopScope,
Logger: logger,
DataConverter: &cadstar.DataConverter{
Logger: logger,
},
ContextPropagators: []workflow.ContextPropagator{
&cad.HeadersContextPropagator{},
},
},
)
service := &cadstar.Service{
Plugins: plugin.Registry,
ClientTaskList: opt.ClientTaskList,
}
service.Register(cadWorker)
if err := cadWorker.Start(); err != nil {
logger.Fatal("Start", zap.Error(err))
}
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
logger.Info("Server started. Press CTRL+C to exit.")
<-sig
cadWorker.Stop()
logger.Info("EXIT.")
}