本文整理汇总了Golang中github.com/cloudfoundry/dropsonde.Initialize函数的典型用法代码示例。如果您正苦于以下问题:Golang Initialize函数的具体用法?Golang Initialize怎么用?Golang Initialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Initialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Parse()
dropsonde.Initialize(metronHostPort, origin)
for {
fmt.Printf(".")
switch filter {
// TODO: Add support for other event types as we add chaining APIs for
// those event types in NOAA.
//case "LogMessage":
//case "HttpStartStop":
//case "HttpStart":
//case "HttpStop":
//case "Error":
case "CounterEvent":
sendCounterEvent()
case "ValueMetric":
sendValueMetric()
case "ContainerMetric":
sendContainerMetric()
default:
sendCounterEvent()
sendValueMetric()
sendContainerMetric()
}
time.Sleep(delay)
}
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:32,代码来源:main.go
示例2: initializeDropsonde
func initializeDropsonde(logger lager.Logger) {
dropsondeDestination := fmt.Sprint("localhost:", *dropsondePort)
err := dropsonde.Initialize(dropsondeDestination, dropsondeOrigin)
if err != nil {
logger.Error("failed to initialize dropsonde: %v", err)
}
}
开发者ID:cf-routing,项目名称:nsync,代码行数:7,代码来源:main.go
示例3: main
func main() {
flag.Parse()
// ** Config Setup
config, err := readConfig(*configFile)
if err != nil {
panic(err)
}
dropsonde.Initialize(config.MetronAddress, "dea_logging_agent")
log := logger.NewLogger(*logLevel, *logFilePath, "deaagent", config.Syslog)
log.Info("Startup: Setting up the loggregator dea logging agent")
// ** END Config Setup
agent := deaagent.NewAgent(*instancesJsonFilePath, log)
go agent.Start()
killChan := signalmanager.RegisterKillSignalChannel()
dumpChan := signalmanager.RegisterGoRoutineDumpSignalChannel()
for {
select {
case <-dumpChan:
signalmanager.DumpGoRoutine()
case <-killChan:
log.Info("Shutting down")
os.Exit(0)
return
}
}
}
开发者ID:lyuyun,项目名称:loggregator,代码行数:33,代码来源:main.go
示例4: main
func main() {
flag.Parse()
config, logger, err := config.ParseConfig(logLevel, configFile, logFilePath)
if err != nil {
panic(err)
}
profiler := profiler.NewProfiler(*cpuprofile, *memprofile, 1*time.Second, logger)
profiler.Profile()
defer profiler.Stop()
uptimeMonitor := monitor.NewUptimeMonitor(time.Duration(config.MonitorIntervalSeconds) * time.Second)
go uptimeMonitor.Start()
defer uptimeMonitor.Stop()
dropsonde.Initialize("localhost:"+strconv.Itoa(config.MetronPort), "LoggregatorTrafficController")
adapter := DefaultStoreAdapterProvider(config.EtcdUrls, config.EtcdMaxConcurrentRequests)
adapter.Connect()
ipAddress, err := localip.LocalIP()
if err != nil {
panic(err)
}
dopplerProxy := makeDopplerProxy(adapter, config, logger)
startOutgoingDopplerProxy(net.JoinHostPort(ipAddress, strconv.FormatUint(uint64(config.OutgoingDropsondePort), 10)), dopplerProxy)
legacyProxy := makeLegacyProxy(adapter, config, logger)
startOutgoingProxy(net.JoinHostPort(ipAddress, strconv.FormatUint(uint64(config.OutgoingPort), 10)), legacyProxy)
rr := routerregistrar.NewRouterRegistrar(config.MbusClient, logger)
uri := "loggregator." + config.SystemDomain
err = rr.RegisterWithRouter(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)
}
uri = "doppler." + config.SystemDomain
err = rr.RegisterWithRouter(ipAddress, config.OutgoingDropsondePort, []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, os.Interrupt)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
rr.UnregisterFromRouter(ipAddress, config.OutgoingPort, []string{uri})
break
}
}
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:58,代码来源:main.go
示例5: main
func main() {
c := config.DefaultConfig()
logCounter := vcap.NewLogCounter()
if configFile != "" {
c = config.InitConfigFromFile(configFile)
}
InitLoggerFromConfig(c, logCounter)
logger := steno.NewLogger("router.main")
err := dropsonde.Initialize(c.Logging.MetronAddress, c.Logging.JobName)
if err != nil {
logger.Errorf("Dropsonde failed to initialize: %s", err.Error())
os.Exit(1)
}
// setup number of procs
if c.GoMaxProcs != 0 {
runtime.GOMAXPROCS(c.GoMaxProcs)
}
if c.DebugAddr != "" {
cf_debug_server.Run(c.DebugAddr)
}
logger.Info("Setting up NATs connection")
natsClient := connectToNatsServer(c, logger)
registry := rregistry.NewRouteRegistry(c, natsClient)
logger.Info("Setting up routing_api route fetcher")
setupRouteFetcher(c, registry)
varz := rvarz.NewVarz(registry)
accessLogger, err := access_log.CreateRunningAccessLogger(c)
if err != nil {
logger.Fatalf("Error creating access logger: %s\n", err)
}
proxy := buildProxy(c, registry, accessLogger, varz)
router, err := router.NewRouter(c, proxy, natsClient, registry, varz, logCounter)
if err != nil {
logger.Errorf("An error occurred: %s", err.Error())
os.Exit(1)
}
errChan := router.Run()
logger.Info("gorouter.started")
waitOnErrOrSignal(c, logger, errChan, router)
os.Exit(0)
}
开发者ID:simonjohansson,项目名称:gorouter,代码行数:57,代码来源:main.go
示例6: main
func main() {
flag.Parse()
config, err := config.ParseConfig(*logLevel, *configFile, *logFilePath)
if err != nil {
panic(err)
}
log := logger.NewLogger(*logLevel, *logFilePath, "loggregator trafficcontroller", config.Syslog)
log.Info("Startup: Setting up the loggregator traffic controller")
dropsonde.Initialize("localhost:"+strconv.Itoa(config.MetronPort), "LoggregatorTrafficController")
profiler := profiler.NewProfiler(*cpuprofile, *memprofile, 1*time.Second, log)
profiler.Profile()
defer profiler.Stop()
uptimeMonitor := monitor.NewUptimeMonitor(time.Duration(config.MonitorIntervalSeconds) * time.Second)
go uptimeMonitor.Start()
defer uptimeMonitor.Stop()
dopplerAdapter := DefaultStoreAdapterProvider(config.EtcdUrls, config.EtcdMaxConcurrentRequests)
dopplerAdapter.Connect()
legacyAdapter := DefaultStoreAdapterProvider(config.EtcdUrls, config.EtcdMaxConcurrentRequests)
legacyAdapter.Connect()
ipAddress, err := localip.LocalIP()
if err != nil {
panic(err)
}
dopplerProxy := makeDopplerProxy(dopplerAdapter, config, log)
startOutgoingDopplerProxy(net.JoinHostPort(ipAddress, strconv.FormatUint(uint64(config.OutgoingDropsondePort), 10)), dopplerProxy)
legacyProxy := makeLegacyProxy(legacyAdapter, config, log)
startOutgoingProxy(net.JoinHostPort(ipAddress, strconv.FormatUint(uint64(config.OutgoingPort), 10)), legacyProxy)
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill, os.Interrupt)
dumpChan := registerGoRoutineDumpSignalChannel()
for {
select {
case <-dumpChan:
logger.DumpGoRoutine()
case <-killChan:
break
}
}
}
开发者ID:pkdevbox,项目名称:loggregator,代码行数:52,代码来源:main.go
示例7: main
func main() {
if dropsondeDestination == "" {
fmt.Println("dropsondeDestination flag is required")
os.Exit(1)
}
if sourceInstance == "" {
fmt.Println("sourceInstance flag is required")
os.Exit(1)
}
args := flag.Args()
if len(args) == 0 {
fmt.Println("Command not specified!")
fmt.Println("Usage: tee2metron -dropsondeDestionation=127.0.0.1:3457 -sourceInstance=cell-21 COMMAND")
os.Exit(3)
}
err := dropsonde.Initialize(dropsondeDestination, sourceInstance, args[0])
if err != nil {
panic("error initializing dropsonde" + err.Error())
}
dropsondeStdoutReader, dropsondeStdoutWriter := io.Pipe()
dropsondeStderrReader, dropsondeStderrWriter := io.Pipe()
stdoutTeeWriter := io.MultiWriter(dropsondeStdoutWriter, os.Stdout)
stderrTeeWriter := io.MultiWriter(dropsondeStderrWriter, os.Stderr)
defer dropsondeStdoutReader.Close()
defer dropsondeStderrReader.Close()
defer dropsondeStdoutWriter.Close()
defer dropsondeStderrWriter.Close()
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdout = stdoutTeeWriter
cmd.Stderr = stderrTeeWriter
go logs.ScanLogStream(latticeDebugStreamId, args[0], sourceInstance, dropsondeStdoutReader)
go logs.ScanErrorLogStream(latticeDebugStreamId, args[0], sourceInstance, dropsondeStderrReader)
err = cmd.Start()
if err != nil {
fmt.Println(err)
os.Exit(3)
}
// if the child is killed abnormally we would know
err = cmd.Wait()
if err != nil {
fmt.Println(args[0], ":", err)
os.Exit(3)
}
}
开发者ID:rajkumargithub,项目名称:lattice,代码行数:52,代码来源:main.go
示例8: main
func main() {
configPath := flag.String("configPath", "", "Path to config file. Optional.")
stateFilePath := flag.String("stateFilePath", "", "Path to state file. Optional.")
flag.Parse()
config = new(observer.Config)
if *configPath != "" {
if err := config.Load(*configPath); err != nil {
errLog.Fatalf("Error loading config file: %s", err.Error())
}
}
state = new(observer.State)
if *stateFilePath != "" {
if _, err := os.Stat(*stateFilePath); os.IsNotExist(err) {
state.Write(*stateFilePath)
}
if err := state.Load(*stateFilePath); err != nil {
errLog.Fatalf("Error loading state file: %s", err.Error())
}
setupExitHandler(*stateFilePath)
defer state.Write(*stateFilePath)
}
handleFn := logEvent
if config.Metron.Endpoint != "" && config.Metron.Origin != "" {
err := dropsonde.Initialize(
config.Metron.Endpoint,
config.Metron.Origin,
)
if err != nil {
errLog.Fatalf("Dropsonde failed to initialize", err)
}
handleFn = func(event observer.AddressChange) {
emitMetric(event)
logEvent(event)
}
}
addrChanges := make(chan observer.AddressChange)
done := make(chan struct{})
go handleObservations(handleFn, addrChanges, done)
observer.Observe(*config, state, addrChanges)
<-done
}
开发者ID:st3v,项目名称:arp-watch,代码行数:50,代码来源:main.go
示例9: main
func main() {
err := dropsonde.Initialize(metronAddr, "METRIC-TEST", "z1", "0")
if err != nil {
println(err.Error())
}
for i := uint64(0); ; i++ {
println("emitting metric at counter: ", i)
metrics.SendContainerMetric(appId, 0, 42.42, 1234, i)
metrics.SendContainerMetric(appId, 1, 11.41, 1234, i)
metrics.SendContainerMetric(appId, 2, 11.41, 1234, i)
metrics.SendContainerMetric("donotseethis", 2, 11.41, 1234, i)
time.Sleep(1 * time.Second)
}
}
开发者ID:Reejoshi,项目名称:cli,代码行数:15,代码来源:main.go
示例10: main
func main() {
redisConn, err := Connect()
if err != nil {
fmt.Println(err)
return
}
defer redisConn.Disconnect()
d := &emitterDetails{
Destination: "localhost:3457",
Origin: "metrics-demo",
Zone: "z1",
Index: "0",
}
err = dropsonde.Initialize(d.Destination, d.Origin, d.Zone, d.Index)
if err != nil {
fmt.Println(err)
return
}
fieldName := "uptime_in_seconds"
uptime, err := redisConn.InfoField(fieldName)
if err != nil {
fmt.Println(err)
return
}
uptimeConverted, err := strconv.ParseFloat(uptime, 64)
if err != nil {
fmt.Println(err)
}
metricData := &metric{
Name: fieldName,
Value: uptimeConverted,
Unit: "",
}
err = redisConn.EmitMetric(metricData)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Successfully emitted %+v", metricData)
}
开发者ID:benlaplanche,项目名称:emitter,代码行数:48,代码来源:main.go
示例11: main
func main() {
cf_debug_server.AddFlags(flag.CommandLine)
cf_lager.AddFlags(flag.CommandLine)
flag.Parse()
cf_http.Initialize(*communicationTimeout)
logger, reconfigurableSink := cf_lager.New("ssh-proxy")
err := dropsonde.Initialize(dropsondeDestination, dropsondeOrigin)
if err != nil {
logger.Error("failed-to-initialize-dropsonde", err)
}
proxyConfig, err := configureProxy(logger)
if err != nil {
logger.Error("configure-failed", err)
os.Exit(1)
}
sshProxy := proxy.New(logger, proxyConfig)
server := server.NewServer(logger, *address, sshProxy)
members := grouper.Members{
{"ssh-proxy", server},
}
if dbgAddr := cf_debug_server.DebugAddress(flag.CommandLine); dbgAddr != "" {
members = append(grouper.Members{{
"debug-server", cf_debug_server.Runner(dbgAddr, reconfigurableSink),
}}, members...)
}
group := grouper.NewOrdered(os.Interrupt, members)
monitor := ifrit.Invoke(sigmon.New(group))
logger.Info("started")
err = <-monitor.Wait()
if err != nil {
logger.Error("exited-with-failure", err)
os.Exit(1)
}
logger.Info("exited")
os.Exit(0)
}
开发者ID:krishicks,项目名称:diego-ssh,代码行数:47,代码来源:main.go
示例12: main
func main() {
err := dropsonde.Initialize("localhost:3457", "METRIC-TEST", "z1", "0")
if err != nil {
println(err.Error())
}
var i uint64
i = 0
for {
println("emitting metric at counter: ", i)
metrics.SendContainerMetric(appID, 0, 42.42, 1234, i)
metrics.SendContainerMetric(appID, 1, 11.41, 1234, i)
metrics.SendContainerMetric(appID, 2, 11.41, 1234, i)
metrics.SendContainerMetric("donotseethis", 2, 11.41, 1234, i)
i++
time.Sleep(1 * time.Second)
}
}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:18,代码来源:container_metrics_emitter.go
示例13: main
func main() {
configFilePath := flag.String("configPath", "", "path to the configuration file")
flag.Parse()
conf := config.Configuration(*configFilePath)
if len(conf.Syslog) > 0 {
logging.SetSysLogger(conf.Syslog)
}
logging.SetLevel(conf.LogLevel)
dropsonde.Initialize("localhost:"+strconv.Itoa(conf.MetronPort), valuemetricsender.ForwarderOrigin)
go func() {
err := tcp.Open(conf.IncomingPort, forwarder.StartMessageForwarder(valuemetricsender.NewValueMetricSender()))
if err != nil {
logging.Log.Panic("Could not open the TCP port", err)
}
}()
logging.Log.Info("Bosh HM forwarder initialized")
infoHandler := handlers.NewInfoHandler()
router := mux.NewRouter()
router.Handle("/info", infoHandler).Methods("GET")
if conf.DebugPort > 0 {
go pprofServer(conf.DebugPort)
}
logging.Log.Info(fmt.Sprintf("Starting Info Server on port %d", conf.InfoPort))
err := http.ListenAndServe(net.JoinHostPort("", fmt.Sprintf("%d", conf.InfoPort)), router)
if err != nil {
logging.Log.Panic("Failed to start up alerter: ", err)
}
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:38,代码来源:main.go
示例14: main
func main() {
flag.StringVar(&configFile, "c", "", "Configuration File")
cf_lager.AddFlags(flag.CommandLine)
flag.Parse()
c := config.DefaultConfig()
logCounter := schema.NewLogCounter()
if configFile != "" {
c = config.InitConfigFromFile(configFile)
}
prefix := "gorouter.stdout"
if c.Logging.Syslog != "" {
prefix = c.Logging.Syslog
}
logger, reconfigurableSink := cf_lager.New(prefix)
InitLoggerFromConfig(logger, c, logCounter)
logger.Info("starting")
err := dropsonde.Initialize(c.Logging.MetronAddress, c.Logging.JobName)
if err != nil {
logger.Fatal("dropsonde-initialize-error", err)
}
// setup number of procs
if c.GoMaxProcs != 0 {
runtime.GOMAXPROCS(c.GoMaxProcs)
}
if c.DebugAddr != "" {
cf_debug_server.Run(c.DebugAddr, reconfigurableSink)
}
logger.Info("setting-up-nats-connection")
natsClient := connectToNatsServer(logger.Session("nats"), c)
logger.Info("Successfully-connected-to-nats")
metricsReporter := metrics.NewMetricsReporter()
registry := rregistry.NewRouteRegistry(logger.Session("registry"), c, metricsReporter)
varz := rvarz.NewVarz(registry)
compositeReporter := metrics.NewCompositeReporter(varz, metricsReporter)
accessLogger, err := access_log.CreateRunningAccessLogger(logger.Session("access-log"), c)
if err != nil {
logger.Fatal("error-creating-access-logger", err)
}
var crypto secure.Crypto
var cryptoPrev secure.Crypto
if c.RouteServiceEnabled {
crypto = createCrypto(logger, c.RouteServiceSecret)
if c.RouteServiceSecretPrev != "" {
cryptoPrev = createCrypto(logger, c.RouteServiceSecretPrev)
}
}
proxy := buildProxy(logger.Session("proxy"), c, registry, accessLogger, compositeReporter, crypto, cryptoPrev)
router, err := router.NewRouter(logger.Session("router"), c, proxy, natsClient, registry, varz, logCounter, nil)
if err != nil {
logger.Fatal("initialize-router-error", err)
}
members := grouper.Members{
{"router", router},
}
if c.RoutingApiEnabled() {
logger.Info("setting-up-routing-api")
routeFetcher := setupRouteFetcher(logger.Session("route-fetcher"), c, registry)
// check connectivity to routing api
err := routeFetcher.FetchRoutes()
if err != nil {
logger.Fatal("routing-api-connection-failed", err)
}
members = append(members, grouper.Member{"router-fetcher", routeFetcher})
}
group := grouper.NewOrdered(os.Interrupt, members)
monitor := ifrit.Invoke(sigmon.New(group, syscall.SIGTERM, syscall.SIGINT, syscall.SIGUSR1))
err = <-monitor.Wait()
if err != nil {
logger.Error("gorouter.exited-with-failure", err)
os.Exit(1)
}
os.Exit(0)
}
开发者ID:rakutentech,项目名称:gorouter,代码行数:93,代码来源:main.go
示例15: main
func main() {
flag.Parse()
// ** Config Setup
config, err := readConfig(*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)
}
}()
}
log := logger.NewLogger(*logLevel, *logFilePath, "deaagent", config.Syslog)
log.Info("Startup: Setting up the loggregator dea logging agent")
// ** END Config Setup
agent := deaagent.NewAgent(*instancesJsonFilePath, log)
go agent.Start()
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Interrupt)
dumpChan := registerGoRoutineDumpSignalChannel()
for {
select {
case <-dumpChan:
logger.DumpGoRoutine()
case <-killChan:
log.Info("Shutting down")
return
}
}
}
开发者ID:hpcloud,项目名称:loggregator-1,代码行数:62,代码来源:main.go
示例16: main
func main() {
seed := time.Now().UnixNano()
rand.Seed(seed)
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
localIp, err := localip.LocalIP()
if err != nil {
panic(errors.New("Unable to resolve own IP address: " + err.Error()))
}
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)
}
}()
}
conf, logger := ParseConfig(logLevel, configFile, logFilePath)
dropsonde.Initialize(conf.MetronAddress, "DopplerServer")
if len(conf.NatsHosts) == 0 {
logger.Warn("Startup: Did not receive a NATS host - not going to regsiter component")
cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
return fakeyagnats.Connect(), nil
}
}
err = conf.Validate(logger)
if err != nil {
panic(err)
}
storeAdapter := NewStoreAdapter(conf.EtcdUrls, conf.EtcdMaxConcurrentRequests)
doppler := New(localIp, conf, logger, storeAdapter, conf.MessageDrainBufferSize, "doppler")
if err != nil {
panic(err)
}
go doppler.Start()
logger.Info("Startup: doppler server started.")
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill, os.Interrupt)
storeAdapter = NewStoreAdapter(conf.EtcdUrls, conf.EtcdMaxConcurrentRequests)
StartHeartbeats(localIp, config.HeartbeatInterval, conf, storeAdapter, logger)
for {
select {
case <-cfcomponent.RegisterGoRoutineDumpSignalChannel():
cfcomponent.DumpGoRoutine()
case <-killChan:
logger.Info("Shutting down")
doppler.Stop()
return
}
}
}
开发者ID:JimmyMa,项目名称:loggregator,代码行数:84,代码来源:main.go
示例17: initializeDropsonde
func (cmd *GuardianCommand) initializeDropsonde(log lager.Logger) {
err := dropsonde.Initialize(cmd.Metrics.DropsondeDestination, cmd.Metrics.DropsondeOrigin)
if err != nil {
log.Error("failed to initialize dropsonde", err)
}
}
开发者ID:cloudfoundry,项目名称:guardian,代码行数:6,代码来源:command.go
示例18: main
func main() {
seed := time.Now().UnixNano()
rand.Seed(seed)
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
localIp, err := localip.LocalIP()
if err != nil {
panic(errors.New("Unable to resolve own IP address: " + err.Error()))
}
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)
}
}()
}
conf, err := config.ParseConfig(*configFile)
if err != nil {
panic(err)
}
log := logger.NewLogger(*logLevel, *logFilePath, "doppler", conf.Syslog)
log.Info("Startup: Setting up the doppler server")
dropsonde.Initialize(conf.MetronAddress, DOPPLER_ORIGIN)
dopplerStoreAdapter := NewStoreAdapter(conf.EtcdUrls, conf.EtcdMaxConcurrentRequests)
legacyStoreAdapter := NewStoreAdapter(conf.EtcdUrls, conf.EtcdMaxConcurrentRequests)
doppler := New(localIp, conf, log, dopplerStoreAdapter, conf.MessageDrainBufferSize, DOPPLER_ORIGIN, time.Duration(conf.SinkDialTimeoutSeconds)*time.Second)
if err != nil {
panic(err)
}
go doppler.Start()
log.Info("Startup: doppler server started.")
killChan := make(chan os.Signal)
signal.Notify(killChan, os.Kill, os.Interrupt)
dumpChan := registerGoRoutineDumpSignalChannel()
releaseNodeChan := announcer.Announce(localIp, config.HeartbeatInterval, conf, dopplerStoreAdapter, log)
legacyReleaseNodeChan := announcer.AnnounceLegacy(localIp, config.HeartbeatInterval, conf, legacyStoreAdapter, log)
for {
select {
case <-dumpChan:
logger.DumpGoRoutine()
case <-killChan:
log.Info("Shutting down")
doppler.Stop()
close(releaseNodeChan)
close(legacyReleaseNodeChan)
return
}
}
}
开发者ID:Jonty,项目名称:loggregator,代码行数:83,代码来源:main.go
示例19: main
func main() {
flag.StringVar(&configFile, "c", "", "Configuration File")
cf_lager.AddFlags(flag.CommandLine)
flag.Parse()
c := config.DefaultConfig()
logCounter := vcap.NewLogCounter()
if configFile != "" {
c = config.InitConfigFromFile(configFile)
}
InitLoggerFromConfig(c, logCounter)
logger := steno.NewLogger("router.main")
err := dropsonde.Initialize(c.Logging.MetronAddress, c.Logging.JobName)
if err != nil {
logger.Errorf("Dropsonde failed to initialize: %s", err.Error())
os.Exit(1)
}
// setup number of procs
if c.GoMaxProcs != 0 {
runtime.GOMAXPROCS(c.GoMaxProcs)
}
if c.DebugAddr != "" {
cf_debug_server.Run(c.DebugAddr)
}
logger.Info("Setting up NATs connection")
natsClient := connectToNatsServer(logger, c)
metricsReporter := metrics.NewMetricsReporter()
registry := rregistry.NewRouteRegistry(c, natsClient, metricsReporter)
varz := rvarz.NewVarz(registry)
compositeReporter := metrics.NewCompositeReporter(varz, metricsReporter)
accessLogger, err := access_log.CreateRunningAccessLogger(c)
if err != nil {
logger.Fatalf("Error creating access logger: %s\n", err)
}
var crypto secure.Crypto
var cryptoPrev secure.Crypto
if c.RouteServiceEnabled {
crypto = createCrypto(logger, c.RouteServiceSecret)
if c.RouteServiceSecretPrev != "" {
cryptoPrev = createCrypto(logger, c.RouteServiceSecretPrev)
}
}
proxy := buildProxy(c, registry, accessLogger, compositeReporter, crypto, cryptoPrev)
router, err := router.NewRouter(c, proxy, natsClient, registry, varz, logCounter, nil)
if err != nil {
logger.Errorf("An error occurred: %s", err.Error())
os.Exit(1)
}
members := grouper.Members{
{"router", router},
}
if c.RoutingApiEnabled() {
logger.Info("Setting up route fetcher")
routeFetcher := setupRouteFetcher(logger, c, registry)
members = append(members, grouper.Member{"router-fetcher", routeFetcher})
}
group := grouper.NewOrdered(os.Interrupt, members)
monitor := ifrit.Invoke(sigmon.New(group, syscall.SIGTERM, syscall.SIGINT, syscall.SIGUSR1))
err = <-monitor.Wait()
if err != nil {
logger.Error("gorouter.exited-with-failure")
os.Exit(1)
}
os.Exit(0)
}
开发者ID:idouba,项目名称:gorouter,代码行数:82,代码来源:main.go
示例20:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("communicating with doppler over TCP", func() {
It("forwards messages", func() {
etcdCleanup, etcdClientURL := integration_tests.SetupEtcd()
defer etcdCleanup()
metronCleanup, metronPort, metronReady := integration_tests.SetupMetron(etcdClientURL, "tcp")
defer metronCleanup()
dopplerCleanup, dopplerOutgoingPort := integration_tests.SetupDoppler(etcdClientURL, metronPort)
defer dopplerCleanup()
metronReady()
err := dropsonde.Initialize(fmt.Sprintf("localhost:%d", metronPort), "test-origin")
Expect(err).NotTo(HaveOccurred())
By("sending a message into metron")
sent := make(chan struct{})
go func() {
defer close(sent)
err = logs.SendAppLog("test-app-id", "An event happened!", "test-app-id", "0")
Expect(err).NotTo(HaveOccurred())
}()
<-sent
By("reading a message from doppler")
Eventually(func() ([]byte, error) {
wsURL := fmt.Sprintf("ws://localhost:%d/apps/test-app-id/recentlogs", dopplerOutgoingPort)
c, _, err := websocket.DefaultDialer.Dial(wsURL, nil)
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:30,代码来源:doppler_tcp_test.go
注:本文中的github.com/cloudfoundry/dropsonde.Initialize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论