-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
42 lines (34 loc) · 1.02 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
// Package main is a module which serves the ocean-prefilter vision service
package main
import (
"context"
"go.viam.com/rdk/services/vision"
"go.viam.com/rdk/logging"
"go.viam.com/rdk/module"
"go.viam.com/utils"
"github.com/viamrobotics/ocean-prefilter/oceanprefilter"
)
func main() {
// NewLoggerFromArgs will create a logging.Logger at "DebugLevel" if
// "--log-level=debug" is an argument in os.Args and at "InfoLevel" otherwise.
utils.ContextualMain(mainWithArgs, module.NewLoggerFromArgs("ocean-prefilter"))
}
func mainWithArgs(ctx context.Context, args []string, logger logging.Logger) (err error) {
myMod, err := module.NewModuleFromArgs(ctx, logger)
if err != nil {
return err
}
// Models and APIs add helpers to the registry during their init().
// They can then be added to the module here.
err = myMod.AddModelFromRegistry(ctx, vision.API, oceanprefilter.Model)
if err != nil {
return err
}
err = myMod.Start(ctx)
defer myMod.Close(ctx)
if err != nil {
return err
}
<-ctx.Done()
return nil
}