-
Notifications
You must be signed in to change notification settings - Fork 474
/
main.go
75 lines (64 loc) · 2.37 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// Copyright (c) 2018
// Cavium
// Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package logging
import (
"context"
"os"
"github.com/edgexfoundry/edgex-go"
"github.com/edgexfoundry/edgex-go/internal"
"github.com/edgexfoundry/edgex-go/internal/pkg/telemetry"
"github.com/edgexfoundry/edgex-go/internal/support/logging/config"
"github.com/edgexfoundry/edgex-go/internal/support/logging/container"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/flags"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/handlers/httpserver"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/handlers/message"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/handlers/secret"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/handlers/testing"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/interfaces"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/startup"
"github.com/edgexfoundry/go-mod-bootstrap/di"
"github.com/edgexfoundry/go-mod-core-contracts/clients"
"github.com/gorilla/mux"
)
func Main(ctx context.Context, cancel context.CancelFunc, router *mux.Router, readyStream chan<- bool) {
startupTimer := startup.NewStartUpTimer(clients.SupportLoggingServiceKey)
// All common command-line flags have been moved to DefaultCommonFlags. Service specific flags can be add here,
// by inserting service specific flag prior to call to commonFlags.Parse().
// Example:
// flags.FlagSet.StringVar(&myvar, "m", "", "Specify a ....")
// ....
// flags.Parse(os.Args[1:])
//
f := flags.New()
f.Parse(os.Args[1:])
configuration := &config.ConfigurationStruct{}
dic := di.NewContainer(di.ServiceConstructorMap{
container.ConfigurationName: func(get di.Get) interface{} {
return configuration
},
})
httpServer := httpserver.NewBootstrap(router, true)
bootstrap.Run(
ctx,
cancel,
f,
clients.SupportLoggingServiceKey,
internal.ConfigStemCore+internal.ConfigMajorVersion,
configuration,
startupTimer,
dic,
[]interfaces.BootstrapHandler{
secret.NewSecret().BootstrapHandler,
NewServiceInit(router, httpServer, clients.SupportLoggingServiceKey).BootstrapHandler,
telemetry.BootstrapHandler,
httpServer.BootstrapHandler,
message.NewBootstrap(clients.SupportLoggingServiceKey, edgex.Version).BootstrapHandler,
testing.NewBootstrap(httpServer, readyStream).BootstrapHandler,
})
}