-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (31 loc) · 913 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
package main
import (
"context"
"flag"
"os"
"os/signal"
"sync"
"github.com/san-lab/udpsigner/cli"
"github.com/san-lab/udpsigner/peers"
"github.com/san-lab/udpsigner/rpc"
"github.com/san-lab/udpsigner/state"
)
func main() {
httpPort := flag.String("httpPort", "8100", "http port")
rpcf := flag.Bool("withHttp", false, "enable service RPC endpoint")
//wauth := flag.Bool("withAuth", true, "should Basic Authentication be enabled")
flag.Parse()
//This is to graciously serve the ^C signal - allow all registered routines to clean up
interruptChan := make(chan os.Signal)
wg := &sync.WaitGroup{}
signal.Notify(interruptChan, os.Interrupt)
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
ctx = context.WithValue(ctx, "WaitGroup", wg)
if *rpcf {
rpc.StartRPC(*httpPort, ctx, cancel, interruptChan)
}
go peers.Initialize(state.CurrentState, ctx)
cli.Top()
wg.Wait()
}