-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (36 loc) · 958 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
38
39
40
41
42
43
44
package main
import (
"context"
"log"
"os"
"os/signal"
)
func main() {
cbkSrv, err := spawnCbkServer(cbkSrvAddr)
if err != nil {
log.Fatalf("spawnCbkServer() failed: %v", err)
}
log.Printf("started reverse proxy; addr=%s", proxySrvAddr)
proxySrv, err := spawnProxyServer(proxySrvAddr)
if err != nil {
log.Fatalf("spawnProxyServer() failed: %v", err)
}
log.Printf("started callback server; addr=%s", cbkSrvAddr)
mainWait := make(chan struct{})
go func() {
sigint := make(chan os.Signal, 1)
signal.Notify(sigint, os.Interrupt)
<-sigint
if err := proxySrv.Shutdown(context.Background()); err != nil {
log.Printf("proxySrv.Shutdown() failed: %s", err.Error())
}
log.Printf("stopped reverse proxy")
if err := cbkSrv.Shutdown(context.Background()); err != nil {
log.Printf("cbkSrv.Shutdown() failed: %s", err.Error())
}
log.Printf("stopped callback server")
close(mainWait)
}()
<-mainWait
log.Printf("fin")
}