...
1 package entrypoint
2
3 import (
4 "context"
5 "net/http"
6 "time"
7
8 "github.com/datawire/ambassador/v2/pkg/acp"
9 "github.com/datawire/dlib/dgroup"
10 "github.com/datawire/dlib/dlog"
11 )
12
13
14
15
16 func bootDemoMode(ctx context.Context, group *dgroup.Group, ambwatch *acp.AmbassadorWatcher) {
17 group.Go("demo_auth", func(ctx context.Context) error {
18 cmd := subcommand(ctx, "/usr/bin/python3", "/ambassador/demo-services/auth.py")
19 return cmd.Run()
20 })
21
22 group.Go("demo_qotm", func(ctx context.Context) error {
23 cmd := subcommand(ctx, "/usr/bin/python3", "/ambassador/demo-services/qotm.py")
24 return cmd.Run()
25 })
26
27
28
29
30
31
32
33
34
35 go func() {
36 for {
37 resp, err := http.Get("http://localhost:8001/ready")
38
39 if err == nil {
40 if resp.StatusCode == 200 {
41
42
43 ambwatch.NoteSnapshotSent()
44 time.Sleep(5 * time.Millisecond)
45 ambwatch.NoteSnapshotProcessed()
46 break
47 }
48 }
49
50 time.Sleep(5 * time.Second)
51 }
52 }()
53
54 go func() {
55
56 for {
57 resp, err := http.Get("http://localhost:8877/ambassador/v0/check_ready")
58
59 if err == nil {
60 if resp.StatusCode == 200 {
61
62 dlog.Infof(ctx, "AMBASSADOR DEMO RUNNING")
63 break
64 }
65 }
66
67 time.Sleep(5 * time.Second)
68 }
69 }()
70 }
71
View as plain text