本文整理汇总了Golang中github.com/cloudfoundry/loggregatorlib/cfcomponent.ReadConfigInto函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadConfigInto函数的具体用法?Golang ReadConfigInto怎么用?Golang ReadConfigInto使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadConfigInto函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ParseConfig
func ParseConfig(logLevel *bool, configFile, logFilePath *string) (*Config, *gosteno.Logger, error) {
config := &Config{OutgoingPort: 8080}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
return nil, nil, err
}
config.setDefaults()
config.Host = net.JoinHostPort(config.Host, strconv.FormatUint(uint64(config.IncomingPort), 10))
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "loggregator trafficcontroller", config.Config)
logger.Info("Startup: Setting up the loggregator traffic controller")
if len(config.NatsHosts) == 0 {
logger.Warn("Startup: Did not receive a NATS host - not going to register component")
cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
return fakeyagnats.Connect(), nil
}
}
err = config.validate(logger)
if err != nil {
return nil, nil, err
}
return config, logger, nil
}
开发者ID:khj0651,项目名称:loggregator,代码行数:25,代码来源:main.go
示例2: ParseConfig
func ParseConfig(logLevel *bool, configFile, logFilePath *string) (*config.Config, *gosteno.Logger) {
config := &config.Config{}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
if config.MonitorIntervalSeconds == 0 {
config.MonitorIntervalSeconds = 60
}
if config.SinkDialTimeoutSeconds == 0 {
config.SinkDialTimeoutSeconds = 1
}
if config.EnableTLSTransport {
cert, err := tls.LoadX509KeyPair(config.TLSListenerConfig.CrtFile, config.TLSListenerConfig.KeyFile)
if err != nil {
panic(err)
}
config.TLSListenerConfig.Cert = cert
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "doppler", config.Config)
logger.Info("Startup: Setting up the doppler server")
return config, logger
}
开发者ID:Amit-PivotalLabs,项目名称:loggregator,代码行数:28,代码来源:main.go
示例3: parseConfig
func parseConfig(debug bool, configFile string, logFilePath string) (metronConfig, *gosteno.Logger) {
config := metronConfig{}
err := cfcomponent.ReadConfigInto(&config, configFile)
if err != nil {
panic(err)
}
logger := cfcomponent.NewLogger(debug, logFilePath, "metron", config.Config)
logger.Info("Startup: Setting up the Metron agent")
return config, logger
}
开发者ID:khj0651,项目名称:loggregator,代码行数:12,代码来源:main.go
示例4: main
func main() {
flag.Parse()
if *version {
fmt.Printf("version: %s\ngitSha: %s\nsourceUrl: https://github.com/cloudfoundry/loggregator/tree/%s\n\n",
versionNumber, gitSha, gitSha)
return
}
config := &Config{OutgoingPort: 8080}
err := cfcomponent.ReadConfigInto(config, *configFile)
config.Host = net.JoinHostPort(config.Host, strconv.FormatUint(uint64(config.IncomingPort), 10))
if err != nil {
panic(err)
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "loggregator trafficcontroller", config.Config)
logger.Info("Startup: Setting up the loggregator traffic controller")
err = config.validate(logger)
if err != nil {
panic(err)
}
router := makeIncomingRouter(config, logger)
startIncomingRouter(router, logger)
proxy := makeOutgoingProxy(router.Component.IpAddress, config, logger)
startOutgoingProxy(proxy)
setupMonitoring(router, config, logger)
rr := routerregistrar.NewRouterRegistrar(config.MbusClient, logger)
uri := "loggregator." + config.SystemDomain
err = rr.RegisterWithRouter(router.Component.IpAddress, config.OutgoingPort, []string{uri})
if err != nil {
logger.Fatalf("Startup: Did not get response from router when greeting. Using default keep-alive for now. Err: %v.", err)
}
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
rr.UnregisterFromRouter(router.Component.IpAddress, config.OutgoingPort, []string{uri})
break
}
}
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:52,代码来源:main.go
示例5: parseConfig
func parseConfig(debug bool, configFile string, logFilePath string) (Config, *gosteno.Logger) {
config := Config{}
err := cfcomponent.ReadConfigInto(&config, configFile)
if err != nil {
panic(err)
}
err = config.validate()
if err != nil {
panic(err)
}
logger := cfcomponent.NewLogger(debug, logFilePath, "syslog_drain_binder", config.Config)
return config, logger
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:16,代码来源:main.go
示例6: ParseConfig
func ParseConfig(logLevel *bool, configFile, logFilePath *string) (*Config, *gosteno.Logger, error) {
config := &Config{OutgoingPort: 8080}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
return nil, nil, err
}
config.setDefaults()
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "loggregator trafficcontroller", config.Config)
logger.Info("Startup: Setting up the loggregator traffic controller")
err = config.validate(logger)
if err != nil {
return nil, nil, err
}
return config, logger, nil
}
开发者ID:jvshahid,项目名称:loggregator,代码行数:17,代码来源:config.go
示例7: main
func main() {
flag.Parse()
// ** Config Setup
config := &Config{}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
dropsonde.Initialize(config.MetronAddress, "dea_logging_agent")
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer func() {
pprof.StopCPUProfile()
f.Close()
}()
}
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
panic(err)
}
go func() {
defer f.Close()
ticker := time.NewTicker(time.Second * 1)
defer ticker.Stop()
for {
<-ticker.C
pprof.WriteHeapProfile(f)
}
}()
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "deaagent", config.Config)
logger.Info("Startup: Setting up the loggregator dea logging agent")
if len(config.NatsHosts) == 0 {
logger.Warn("Startup: Did not receive a NATS host - not going to register component")
cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
return fakeyagnats.Connect(), nil
}
}
err = config.validate(logger)
if err != nil {
panic(err)
}
// ** END Config Setup
agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
go agent.Start()
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Interrupt)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
logger.Info("Shutting down")
return
}
}
}
开发者ID:Amit-PivotalLabs,项目名称:loggregator,代码行数:73,代码来源:main.go
示例8: main
func main() {
flag.Parse()
if *version {
fmt.Printf("version: %s\ngitSha: %s\nsourceUrl: https://github.com/cloudfoundry/loggregator/tree/%s\n\n",
versionNumber, gitSha, gitSha)
return
}
// ** Config Setup
config := &Config{}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "deaagent", config.Config)
logger.Info("Startup: Setting up the loggregator dea logging agent")
err = config.validate(logger)
if err != nil {
panic(err)
}
// ** END Config Setup
loggregatorEmitter, err := emitter.NewEmitter(config.LoggregatorAddress, "APP", "NA", config.SharedSecret, logger)
if err != nil {
panic(err)
}
agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
cfc, err := cfcomponent.NewComponent(
logger,
"LoggregatorDeaAgent",
config.Index,
&DeaAgentHealthMonitor{},
config.VarzPort,
[]string{config.VarzUser, config.VarzPass},
[]instrumentation.Instrumentable{loggregatorEmitter.LoggregatorClient},
)
if err != nil {
panic(err)
}
cr := collectorregistrar.NewCollectorRegistrar(config.MbusClient, logger)
err = cr.RegisterWithCollector(cfc)
if err != nil {
panic(err)
}
go func() {
err := cfc.StartMonitoringEndpoints()
if err != nil {
panic(err)
}
}()
go agent.Start(loggregatorEmitter)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
}
}
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:68,代码来源:main.go
示例9: main
func main() {
flag.Parse()
if *version {
fmt.Printf("version: %s\ngitSha: %s\nsourceUrl: https://github.com/cloudfoundry/loggregator/tree/%s\n\n",
versionNumber, gitSha, gitSha)
return
}
// ** Config Setup
config := &Config{}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer func() {
pprof.StopCPUProfile()
f.Close()
}()
}
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
panic(err)
}
go func() {
defer f.Close()
ticker := time.NewTicker(time.Second * 1)
defer ticker.Stop()
for {
<-ticker.C
pprof.WriteHeapProfile(f)
}
}()
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "deaagent", config.Config)
logger.Info("Startup: Setting up the loggregator dea logging agent")
err = config.validate(logger)
if err != nil {
panic(err)
}
// ** END Config Setup
loggregatorEmitter, err := emitter.NewEmitter(config.LoggregatorAddress, "APP", "NA", config.SharedSecret, logger)
if err != nil {
panic(err)
}
agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
cfc, err := cfcomponent.NewComponent(
logger,
"LoggregatorDeaAgent",
config.Index,
&DeaAgentHealthMonitor{},
config.VarzPort,
[]string{config.VarzUser, config.VarzPass},
[]instrumentation.Instrumentable{loggregatorEmitter.LoggregatorClient},
)
if err != nil {
panic(err)
}
cr := collectorregistrar.NewCollectorRegistrar(config.MbusClient, logger)
err = cr.RegisterWithCollector(cfc)
if err != nil {
panic(err)
}
go func() {
err := cfc.StartMonitoringEndpoints()
if err != nil {
panic(err)
}
}()
go agent.Start(loggregatorEmitter)
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill, os.Interrupt)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
logger.Info("Shutting down")
return
}
//.........这里部分代码省略.........
开发者ID:robsonmwoc,项目名称:loggregator,代码行数:101,代码来源:main.go
示例10: main
func main() {
flag.Parse()
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "udprouter")
if *version {
fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
return
}
config := &Config{Host: "0.0.0.0:3456", WebPort: 8080}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
err = config.validate(logger)
if err != nil {
panic(err)
}
h := loggregatorrouter.NewHasher(config.Loggregators)
r, err := loggregatorrouter.NewRouter(config.Host, h, config.Config, logger)
if err != nil {
panic(err)
}
redirector := loggregatorrouter.NewRedirector(net.JoinHostPort(r.Component.IpAddress, strconv.Itoa(int(config.WebPort))), h, logger)
go func() {
err := redirector.Start()
if err != nil {
panic(err)
}
}()
rr := routerregistrar.NewRouterRegistrar(config.MbusClient, logger)
uri := "loggregator." + config.SystemDomain
err = rr.RegisterWithRouter(r.Component.IpAddress, config.WebPort, []string{uri})
if err != nil {
logger.Fatalf("Did not get response from router when greeting. Using default keep-alive for now. Err: %v.", err)
}
cr := collectorregistrar.NewCollectorRegistrar(config.MbusClient, logger)
err = cr.RegisterWithCollector(r.Component)
if err != nil {
panic(err)
}
go func() {
err := r.StartMonitoringEndpoints()
if err != nil {
panic(err)
}
}()
go r.Start(logger)
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
rr.UnregisterFromRouter(r.Component.IpAddress, config.WebPort, []string{uri})
break
}
}
}
开发者ID:narayana1208,项目名称:loggregator,代码行数:68,代码来源:main.go
示例11: main
func main() {
seed := time.Now().UnixNano()
rand.Seed(seed)
flag.Parse()
if *version {
fmt.Printf("version: %s\ngitSha: %s\nsourceUrl: https://github.com/cloudfoundry/loggregator/tree/%s\n\n",
versionNumber, gitSha, gitSha)
return
}
runtime.GOMAXPROCS(runtime.NumCPU())
config := &Config{IncomingPort: 3456, OutgoingPort: 8080}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "loggregator", config.Config)
logger.Info("Startup: Setting up the loggregator server")
err = config.validate(logger)
if err != nil {
panic(err)
}
listener := agentlistener.NewAgentListener(fmt.Sprintf("0.0.0.0:%d", config.IncomingPort), logger)
incomingData := listener.Start()
messageRouter := sinkserver.NewMessageRouter(config.MaxRetainedLogMessages, logger)
unmarshaller := func(data []byte) (*logmessage.Message, error) {
return logmessage.ParseEnvelope(data, config.SharedSecret)
}
httpServer := sinkserver.NewHttpServer(messageRouter, 30*time.Second, unmarshaller, logger)
cfc, err := cfcomponent.NewComponent(
logger,
"LoggregatorServer",
config.Index,
&LoggregatorServerHealthMonitor{},
config.VarzPort,
[]string{config.VarzUser, config.VarzPass},
[]instrumentation.Instrumentable{listener, messageRouter},
)
if err != nil {
panic(err)
}
cr := collectorregistrar.NewCollectorRegistrar(config.MbusClient, logger)
err = cr.RegisterWithCollector(cfc)
if err != nil {
logger.Warnf("Unable to register with collector. Err: %v.", err)
}
go func() {
err := cfc.StartMonitoringEndpoints()
if err != nil {
panic(err)
}
}()
go messageRouter.Start()
go httpServer.Start(incomingData, fmt.Sprintf("0.0.0.0:%d", config.OutgoingPort))
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
break
}
}
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:81,代码来源:main.go
示例12: main
func main() {
flag.Parse()
if *version {
fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
return
}
runtime.GOMAXPROCS(runtime.NumCPU())
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "loggregator")
config := &Config{SourcePort: 3456, WebPort: 8080, UaaVerificationKeyFile: *uaaVerificationKeyFile}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
err = config.validate(logger)
if err != nil {
panic(err)
}
listener := agentlistener.NewAgentListener(fmt.Sprintf("0.0.0.0:%d", config.SourcePort), logger)
incomingData := listener.Start()
authorizer := authorization.NewLogAccessAuthorizer(config.decoder, config.ApiHost)
sinkServer := sinkserver.NewSinkServer(
messagestore.NewMessageStore(config.MaxRetainedLogMessages),
logger,
authorizer,
30*time.Second,
)
cfc, err := cfcomponent.NewComponent(
config.WebPort,
"LoggregatorServer",
config.Index,
&LoggregatorServerHealthMonitor{},
config.VarzPort,
[]string{config.VarzUser, config.VarzPass},
[]instrumentation.Instrumentable{listener, sinkServer},
)
if err != nil {
panic(err)
}
rr := routerregistrar.NewRouterRegistrar(config.MbusClient, logger)
uri := servernamer.ServerName(
net.JoinHostPort(cfc.IpAddress, strconv.Itoa(int(config.SourcePort))),
"loggregator."+config.SystemDomain)
err = rr.RegisterWithRouter(cfc.IpAddress, config.WebPort, []string{uri})
if err != nil {
logger.Fatalf("Did not get response from router when greeting. Using default keep-alive for now. Err: %v.", err)
}
cr := collectorregistrar.NewCollectorRegistrar(config.MbusClient, logger)
err = cr.RegisterWithCollector(cfc)
if err != nil {
logger.Warnf("Unable to register with collector. Err: %v.", err)
}
go func() {
err := cfc.StartMonitoringEndpoints()
if err != nil {
panic(err)
}
}()
go sinkServer.Start(incomingData, fmt.Sprintf("0.0.0.0:%d", config.WebPort))
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
rr.UnregisterFromRouter(cfc.IpAddress, cfc.WebPort, []string{uri})
break
}
}
}
开发者ID:narayana1208,项目名称:loggregator,代码行数:85,代码来源:main.go
示例13: main
func main() {
flag.Parse()
if *version {
fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
return
}
logger := cfcomponent.NewLogger(*logLevel, *logFilePath, "deaagent")
// ** Config Setup
config := &Config{}
err := cfcomponent.ReadConfigInto(config, *configFile)
if err != nil {
panic(err)
}
err = config.validate(logger)
if err != nil {
panic(err)
}
// ** END Config Setup
loggregatorClient := loggregatorclient.NewLoggregatorClient(config.LoggregatorAddress, logger, 4096)
agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
cfc, err := cfcomponent.NewComponent(
0,
"LoggregatorDeaAgent",
config.Index,
&DeaAgentHealthMonitor{},
config.VarzPort,
[]string{config.VarzUser, config.VarzPass},
[]instrumentation.Instrumentable{loggregatorClient},
)
if err != nil {
panic(err)
}
cr := collectorregistrar.NewCollectorRegistrar(config.MbusClient, logger)
err = cr.RegisterWithCollector(cfc)
if err != nil {
panic(err)
}
go func() {
err := cfc.StartMonitoringEndpoints()
if err != nil {
panic(err)
}
}()
go agent.Start(loggregatorClient)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
}
}
}
开发者ID:narayana1208,项目名称:loggregator,代码行数:63,代码来源:main.go
注:本文中的github.com/cloudfoundry/loggregatorlib/cfcomponent.ReadConfigInto函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论