forked from philips-labs/medical-delivery-drone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
37 lines (28 loc) · 699 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"
"log"
"os"
"os/signal"
"github.com/philips-labs/medical-delivery-drone/drone"
"github.com/philips-labs/medical-delivery-drone/video"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
go gracefulShutdown(cancel)
converter, err := video.NewConverter()
if err != nil {
return
}
defer converter.Close()
videoChan, err := drone.Connect(ctx, converter)
err = video.Display(ctx, videoChan)
log.Println("Shutdown, completed")
}
func gracefulShutdown(cancel context.CancelFunc) {
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
sig := <-quit
log.Println("Shutting down, reason:", sig.String())
cancel()
}