func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClient := http_client_builder.New().WithoutProxy().Build() requestbuilder_executor := aptly_requestbuilder_executor.New(httpClient.Do) requestbuilder := http_requestbuilder.NewHTTPRequestBuilderProvider() repo_publisher := aptly_repo_publisher.New(requestbuilder_executor, requestbuilder) repo_creater := aptly_repo_creater.New(requestbuilder_executor, requestbuilder, repo_publisher.PublishNewRepo) if len(*repoURLPtr) == 0 { *repoURLPtr = *apiURLPtr } err := do( repo_creater, *repoURLPtr, *apiURLPtr, *apiUserPtr, *apiPasswordPtr, *apiPasswordFilePtr, *repoPtr, *distributionPtr, strings.Split(*architecturePtr, ","), ) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) commandListProvider := func() command_list.CommandList { return command_list.New() } config_parser := debian_config_parser.New() copier := debian_copier.New() zipExtractor := debian_zip_extractor.New() tarGzExtractor := debian_tar_gz_extractor.New() httpClientBuilder := http_client_builder.New().WithoutProxy() httpClient := httpClientBuilder.Build() requestbuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() debianPackageCreator := debian_package_creator.New(commandListProvider, copier, tarGzExtractor.ExtractTarGz, zipExtractor.ExtractZip, httpClient.Do, requestbuilderProvider.NewHTTPRequestBuilder) creatorByReader := debian_package_creator_by_reader.New(commandListProvider, debianPackageCreator, tarGzExtractor.ExtractTarGz) debianPackageCreatorArchive := debian_package_creator_archive.New(creatorByReader.CreatePackage) err := do( debianPackageCreatorArchive, config_parser, *tarGzPathPtr, *configPtr, *versionPtr, *targetDirPtr, ) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClientBuilder := http_client_builder.New() httpClient := httpClientBuilder.Build() latestInformations := atlassian_utils_latest_information.New(bitbucket.JSON_URL, httpClient.Get) latestUrl := atlassian_utils_latest_tar_gz_url.New(latestInformations.VersionInformations) latestVersion := atlassian_utils_latest_version.New(latestInformations.VersionInformations) commandListProvider := func() command_list.CommandList { return command_list.New() } config_parser := debian_config_parser.New() copier := debian_copier.New() zipExtractor := debian_zip_extractor.New() tarGzExtractor := debian_tar_gz_extractor.New() requestbuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() debianPackageCreator := debian_package_creator.New(commandListProvider, copier, tarGzExtractor.ExtractTarGz, zipExtractor.ExtractZip, httpClient.Do, requestbuilderProvider.NewHTTPRequestBuilder) creatorByReader := debian_package_creator_by_reader.New(commandListProvider, debianPackageCreator, tarGzExtractor.ExtractTarGz) latestDebianPackageCreator := debian_latest_package_creator.New(httpClient.Get, latestUrl.LatestConfluenceTarGzUrl, latestVersion.LatestVersion, creatorByReader.CreatePackage) err := do( latestDebianPackageCreator.CreateLatestDebianPackage, config_parser, *configPtr, latestVersion.LatestVersion, *targetDirPtr, ) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClient := http_client_builder.New().WithoutProxy().Build() httpRequestBuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() package_lister := aptly_package_lister.New(httpClient.Do, httpRequestBuilderProvider.NewHTTPRequestBuilder) if len(*repoURLPtr) == 0 { *repoURLPtr = *apiURLPtr } writer := os.Stdout err := do( writer, package_lister, *repoURLPtr, *apiURLPtr, *apiUserPtr, *apiPasswordPtr, *apiPasswordFilePtr, *repoPtr, ) if err != nil { glog.Exit(err) } }
// The main function sets up the connection to the storage backend for // aggregated events (e.g. MongoDB) and fires up an HTTPs server which acts as // an endpoint for docker notifications. func main() { flag.Parse() rand.Seed(time.Now().UnixNano()) glog.CopyStandardLogTo("INFO") // Create our application context ctx, _ := NewAppContext() // Load config file given by first argument configFilePath := flag.Arg(0) if configFilePath == "" { glog.Exit("Config file not specified") } c, err := LoadConfig(configFilePath) if err != nil { glog.Exit(err) } ctx.Config = c // Connect to MongoDB session, err := createMongoDbSession(c) if err != nil { glog.Exit(err) } defer session.Close() ctx.Session = session // Wait for errors on inserts and updates and for flushing changes to disk session.SetSafe(&mgo.Safe{FSync: true}) collection := ctx.Session.DB(ctx.Config.DialInfo.DialInfo.Database).C(ctx.Config.Collection) // The repository structure shall have a uniqe key on the repository's // name field index := mgo.Index{ Key: []string{"repositoryname"}, Unique: true, DropDups: true, Background: true, Sparse: true, } if err = collection.EnsureIndex(index); err != nil { glog.Exitf("It looks like your mongo database is incosinstent. ", "Make sure you have no duplicate entries for repository names.") } // Setup HTTP endpoint var httpConnectionString = ctx.Config.GetEndpointConnectionString() glog.Infof("About to listen on \"%s%s\".", httpConnectionString, ctx.Config.Server.Route) mux := http.NewServeMux() appHandler := &appHandler{ctx: ctx} mux.Handle(ctx.Config.Server.Route, appHandler) err = http.ListenAndServeTLS(httpConnectionString, ctx.Config.Server.Ssl.Cert, ctx.Config.Server.Ssl.CertKey, mux) if err != nil { glog.Exit(err) } glog.Info("Exiting.") }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClientBuilder := http_client_builder.New().WithoutProxy() httpClient := httpClientBuilder.Build() requestbuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() downloader := debian_url_downloader.New(httpClient.Do, requestbuilderProvider.NewHTTPRequestBuilder) lineInspector := debian_line_inspector.New(downloader.DownloadURL) hasChanged := debian_apt_source_has_changed.New(lineInspector.HasLineChanged) bool, err := do( hasChanged, *pathPtr, ) if err != nil { glog.Exit(err) } if bool { glog.Flush() os.Exit(0) } else { glog.Flush() os.Exit(1) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClient := http_client_builder.New().WithoutProxy().Build() httpRequestBuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() packageLister := aptly_package_lister.New(httpClient.Do, httpRequestBuilderProvider.NewHTTPRequestBuilder) requestbuilder_executor := aptly_requestbuilder_executor.New(httpClient.Do) repoPublisher := aptly_repo_publisher.New(requestbuilder_executor, httpRequestBuilderProvider) packageDeleter := aptly_package_deleter.New(httpClient.Do, httpRequestBuilderProvider.NewHTTPRequestBuilder, repoPublisher.PublishRepo) repoCleaner := aptly_repo_cleaner.New(packageDeleter.DeletePackagesByKey, packageLister.ListPackages) if len(*repoURLPtr) == 0 { *repoURLPtr = *apiURLPtr } err := do( repoCleaner, *repoURLPtr, *apiURLPtr, *apiUserPtr, *apiPasswordPtr, *apiPasswordFilePtr, *repoPtr, *distributionPtr, ) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) commandListProvider := func() debian_command_list.CommandList { return debian_command_list.New() } configBuilderWithConfig := func(config *debian_config.Config) debian_config_builder.ConfigBuilder { return debian_config_builder.NewWithConfig(config) } config_parser := debian_config_parser.New() copier := debian_copier.New() zipExtractor := debian_zip_extractor.New() tarGzExtractor := debian_tar_gz_extractor.New() httpClientBuilder := http_client_builder.New().WithoutProxy() httpClient := httpClientBuilder.Build() requestbuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() debianPackageCreator := debian_package_creator.New(commandListProvider, copier, tarGzExtractor.ExtractTarGz, zipExtractor.ExtractZip, httpClient.Do, requestbuilderProvider.NewHTTPRequestBuilder) err := do(config_parser, configBuilderWithConfig, debianPackageCreator, *configPtr, *namePtr, *versionPtr, *sourcePtr, *targetPtr) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClientBuilder := http_client_builder.New() httpClient := httpClientBuilder.Build() latestVersion := sonar_latest_version.New(httpClient.Get) urlByVersion := url_by_version.New() latestUrl := sonar_latest_zip_url.New(latestVersion.LatestSonarVersion, urlByVersion.SonarZipUrlForVersion) commandListProvider := func() command_list.CommandList { return command_list.New() } config_parser := debian_config_parser.New() copier := debian_copier.New() zipExtractor := debian_zip_extractor.New() tarGzExtractor := debian_tar_gz_extractor.New() requestbuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() debianPackageCreator := debian_package_creator.New(commandListProvider, copier, tarGzExtractor.ExtractTarGz, zipExtractor.ExtractZip, httpClient.Do, requestbuilderProvider.NewHTTPRequestBuilder) creatorByReader := debian_package_creator_by_reader.New(commandListProvider, debianPackageCreator, zipExtractor.ExtractZip) latestDebianPackageCreator := debian_latest_package_creator.New(httpClient.Get, latestUrl.LatestSonarZipUrl, latestVersion.LatestSonarVersion, creatorByReader.CreatePackage) writer := os.Stdout err := do(writer, latestDebianPackageCreator.CreateLatestDebianPackage, config_parser.ParseFileToConfig, latestVersion.LatestSonarVersion, *configPtr) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) if err := do(); err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) writer := os.Stdout httpClientBuilder := http_client_builder.New() httpClient := httpClientBuilder.Build() latestVersion := latest_version.New(httpClient.Get) err := do(writer, latestVersion.LatestGolangVersion) if err != nil { glog.Exit(err) } }
func main() { defer serviceability.BehaviorOnPanic(os.Getenv("OPENSHIFT_ON_PANIC"))() defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop() glog.CopyStandardLogTo("INFO") if len(os.Getenv("GOMAXPROCS")) == 0 { runtime.GOMAXPROCS(runtime.NumCPU()) } basename := filepath.Base(os.Args[0]) command := openshift.CommandFor(basename) if err := command.Execute(); err != nil { os.Exit(1) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) writer := os.Stdout httpClientBuilder := http_client_builder.New() httpClient := httpClientBuilder.Build() latestVersion := latest_version.New(httpClient.Get) urlByVersion := url_by_version.New() latestZipUrl := latest_zip_url.New(latestVersion.LatestSonarVersion, urlByVersion.SonarZipUrlForVersion) err := do(writer, latestZipUrl.LatestSonarZipUrl) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) z := zip_extractor.New() err := do( z.ExtractZipFile, *zipPtr, *targetPtr, ) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClientBuilder := http_client_builder.New() httpClient := httpClientBuilder.Build() bambooLatestInformations := atlassian_utils_latest_information.New(bamboo.JSON_URL, httpClient.Get) bambooLatestVersion := atlassian_utils_latest_version.New(bambooLatestInformations.VersionInformations) confluenceLatestInformations := atlassian_utils_latest_information.New(confluence.JSON_URL, httpClient.Get) confluenceLatestVersion := atlassian_utils_latest_version.New(confluenceLatestInformations.VersionInformations) jiraCorelatestInformations := atlassian_utils_latest_information.New(jira_core.JSON_URL, httpClient.Get) jiraCoreLatestVersion := atlassian_utils_latest_version.New(jiraCorelatestInformations.VersionInformations) jiraServiceDeskLatestInformations := atlassian_utils_latest_information.New(jira_servicedesk.JSON_URL, httpClient.Get) jiraServiceDeskLatestVersion := atlassian_utils_latest_version.New(jiraServiceDeskLatestInformations.VersionInformations) jiraSoftwareLatestInformations := atlassian_utils_latest_information.New(jira_software.JSON_URL, httpClient.Get) jiraSoftwareLatestVersion := atlassian_utils_latest_version.New(jiraSoftwareLatestInformations.VersionInformations) bitbucketLatestInformations := atlassian_utils_latest_information.New(bitbucket.JSON_URL, httpClient.Get) bitbucketLatestVersion := atlassian_utils_latest_version.New(bitbucketLatestInformations.VersionInformations) crowdLatestInformations := atlassian_utils_latest_information.New(crowd.JSON_URL, httpClient.Get) crowdLatestVersion := atlassian_utils_latest_version.New(crowdLatestInformations.VersionInformations) writer := os.Stdout err := do( writer, bambooLatestVersion.LatestVersion, confluenceLatestVersion.LatestVersion, jiraCoreLatestVersion.LatestVersion, jiraServiceDeskLatestVersion.LatestVersion, jiraSoftwareLatestVersion.LatestVersion, bitbucketLatestVersion.LatestVersion, crowdLatestVersion.LatestVersion, ) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClient := http_client_builder.New().WithoutProxy().Build() httpRequestBuilderProvider := http_requestbuilder.NewHTTPRequestBuilderProvider() requestbuilder_executor := aptly_requestbuilder_executor.New(httpClient.Do) requestbuilder := http_requestbuilder.NewHTTPRequestBuilderProvider() repo_publisher := aptly_repo_publisher.New(requestbuilder_executor, requestbuilder) packageUploader := aptly_package_uploader.New(requestbuilder_executor, requestbuilder, repo_publisher.PublishRepo) packageCopier := aptly_package_copier.New(packageUploader, requestbuilder, httpClient.Do) packageLister := aptly_package_lister.New(httpClient.Do, httpRequestBuilderProvider.NewHTTPRequestBuilder) packageDetailLister := aptly_model_lister.New(packageLister.ListPackages) packageVersion := aptly_package_versions.New(packageDetailLister.ListPackageDetails) packageLastestVersion := aptly_package_latest_version.New(packageVersion.PackageVersions) packageDetailLatestLister := aptly_model_latest_lister.New(packageDetailLister.ListPackageDetails) if len(*repoURLPtr) == 0 { *repoURLPtr = *apiURLPtr } err := do( packageCopier, packageLastestVersion, packageDetailLatestLister, *repoURLPtr, *apiURLPtr, *apiUserPtr, *apiPasswordPtr, *apiPasswordFilePtr, *sourcePtr, *targetPtr, *targetDistributionPtr, *namePtr, *versionPtr, ) if err != nil { glog.Exit(err) } }
func main() { flag.Parse() rand.Seed(time.Now().UnixNano()) glog.CopyStandardLogTo("INFO") cf := flag.Arg(0) if cf == "" { glog.Exitf("Config file not specified") } c, err := server.LoadConfig(cf) if err != nil { glog.Exitf("Failed to load config: %s", err) } rs := RestartableServer{ configFile: cf, hd: &httpdown.HTTP{}, } rs.Serve(c) }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClientBuilder := http_client_builder.New() httpClient := httpClientBuilder.Build() latestInformations := atlassian_utils_latest_information.New(bitbucket.JSON_URL, httpClient.Get) latestUrl := atlassian_utils_latest_tar_gz_url.New(latestInformations.VersionInformations) writer := os.Stdout err := do( writer, latestUrl.LatestConfluenceTarGzUrl, ) if err != nil { glog.Exit(err) } }
func main() { defer glog.Flush() glog.CopyStandardLogTo("info") flag.Parse() runtime.GOMAXPROCS(runtime.NumCPU()) httpClientBuilder := http_client_builder.New() httpClient := httpClientBuilder.Build() latestInformations := atlassian_utils_latest_information.New(crowd.JSON_URL, httpClient.Get) latestVersion := atlassian_utils_latest_version.New(latestInformations.VersionInformations) writer := os.Stdout err := do( writer, latestVersion.LatestVersion, ) if err != nil { glog.Exit(err) } }
func main() { if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } flag.StringVar(&addr, "addr", addr, "监听地址,如\":8080\", 默认: \":8080\"") flag.Parse() defer glog.Flush() glog.CopyStandardLogTo("INFO") m := martini.Classic() m.Use(martini.Static("static", martini.StaticOptions{Prefix: "static"})) m.Group("/json", func(r martini.Router) { r.Group("/namespace", comm.Namespaces) }) m.Get("/", serveTemplate) m.RunOnAddr(addr) }
func main() { flag.Parse() glog.CopyStandardLogTo("info") defer glog.Flush() log.Println("log.println") glog.Infof("info") glog.Warningf("warn") glog.Errorf("error") glog.V(0).Infof("v=0") glog.V(1).Infof("v=1") glog.V(2).Infof("v=2") glog.V(3).Infof("v=3") if glog.V(2) { glog.Infof("if v=2") } // glog.Fatalf("Initialization failed: %s", fmt.Errorf("foo")) }
func main() { if os.Getenv("GOMAXPROCS") == "" { runtime.GOMAXPROCS(runtime.NumCPU()) } cType := flag.String("type", "ws", "comet服务类型,可选:1)ws, 2)udp") addr := flag.String("hudp", ":7999", "UDP监听地址") apiUrl := flag.String("hurl", "", "HTTP服务器根URL(eg: http://127.0.0.1:8080)") serveUdpAddr := flag.String("hhttp", ":8081", "UDP服务器提供HTTP服务的地址") rh := flag.String("rh", "193.168.1.224:6379", "Redis服务器地址") lHost := flag.String("ports", ":1234,:1235", "监听的websocket地址") zkHosts := flag.String("zks", "193.168.1.221,193.168.1.222,193.168.1.223", "设置ZK的地址,多个地址用逗号分割") flag.StringVar(&gLocalAddr, "lip", "", "comet服务器本地地址") flag.StringVar(&gStatusAddr, "sh", ":29999", "程序状态http服务端口") flag.StringVar(&gMsgbusRoot, "zkroot", "MsgBusServers", "zookeeper服务中msgbus所在的根节点名") flag.StringVar(&gCometRoot, "zkrootc", "CometServers", "zookeeper服务中comet所在的根节点名") flag.IntVar(&gUdpTimeout, "uto", gUdpTimeout, "客户端UDP端口失效时长(秒)") flag.BoolVar(&gCometPushUdp, "up", false, "UDP服务器是否向设备推送消息(系统中应该有一个并且唯一的推送UDP消息的Comet服务器)") flag.BoolVar(&gCometUdpSubBindingEvent, "us", false, "UDP服务器是否处理设备绑定/解绑消息(系统中应该有一个并且唯一设置为true的Comet服务器)") printVer := flag.Bool("ver", false, "Comet版本") flag.Parse() if *printVer { fmt.Printf("Comet %s, 插座后台代理服务器.\n", ver.Version) return } switch *cType { case "ws": gCometType = msgs.CometWs case "udp": gCometType = msgs.CometUdp } defer glog.Flush() glog.CopyStandardLogTo("INFO") InitStat(gStatusAddr) InitRedix(*rh) if err := ClearRedis(gLocalAddr); err != nil { glog.Fatalf("ClearRedis before starting failed: %v", err) } go InitZK(strings.Split(*zkHosts, ","), gMsgbusRoot, gCometRoot) gSessionList = InitSessionList() switch gCometType { case msgs.CometWs: if len(gLocalAddr) == 0 { glog.Fatalf("必须指定本机IP") } StartHttp(strings.Split(*lHost, ",")) case msgs.CometUdp: if _, e := url.Parse(*apiUrl); len(*apiUrl) == 0 || e != nil { glog.Fatalf("Invalid argument of '-hurl': %s, error: %v", *apiUrl, e) } handler := NewHandler(*apiUrl, *serveUdpAddr) server := NewUdpServer(*addr, handler) handler.Server = server gUdpSessions.server = server go handler.Run() ///api/device/udpadr go server.RunLoop() default: glog.Fatalf("undifined argument for \"-type\"") } handleSignal(func() { CloseZK() glog.Info("Closed Server") }) }
func init() { glog.CopyStandardLogTo("INFO") }
func main() { // get config //flag.StringVar(&gZkIp, "zh", "", "rabbitmq注册到zookeeper中的ip") flag.StringVar(&gAddr, "h", "127.0.0.1:5672", "rabbitmq的监听ip") flag.StringVar(&gAPIUrl, "url", "http://*****:*****@127.0.0.1:15672", "rabbitmq的API URL地址") flag.StringVar(&gVhost, "vh", "/", "测试rabbitmq的心跳API使用的vhost名") flag.DurationVar(&gHeartbeatDur, "d", 10*time.Second, "测试rabbitmq的心跳间隔") zks := flag.String("zks", "", "zookeeper地址, 可用\",\"分隔的多个ip") zkRoot := flag.String("zkroot", "rabbitmq", "将rabbitmq注册到zookeeper的该节点下") printVer := flag.Bool("ver", false, "Comet版本") flag.Parse() glog.CopyStandardLogTo("INFO") if *printVer { fmt.Printf("Comet %s, 插座后台代理服务器.\n", VERSION) return } defer glog.Flush() // new code InitZK(strings.Split(*zks, ","), *zkRoot) u, err := url.Parse(gAPIUrl) if err != nil { glog.Fatalf("Parse API URL (%s) failed: %v", gAPIUrl, err) return } u.Path = "/api/aliveness-test/" apiUrl := u.String() + url.QueryEscape(gVhost) opaque := u.Path + url.QueryEscape(gVhost) onlinedLast := false glog.Infof("Start hearbeat of %s", apiUrl) for { r, err := http.NewRequest("GET", apiUrl, nil) if err != nil { glog.Fatal("NewRequest from url %s failed: %v", apiUrl, err) } r.URL.Opaque = opaque response, err := http.DefaultClient.Do(r) onlinedNow := false if err == nil { buf, err := ioutil.ReadAll(response.Body) if err == nil { ret := ApiResult{} err = json.Unmarshal(buf, &ret) if err == nil { onlinedNow = (ret.Status == "ok") } else { glog.Errorf("Unmarshal json failed: %v, body: %s", err, string(buf)) } } else { glog.Errorf("Read HTTP body failed: %v", err) } err = response.Body.Close() if err != nil { glog.Errorf("Close body error: %v", err) } } else { glog.Errorf("Get aliveness test failed: %v", err) } if onlinedLast != onlinedNow { onlinedLast = onlinedNow if onlinedNow { OnlineRmq() glog.Infof("onlined") } else { OfflineRmq() glog.Infof("offlined") } } time.Sleep(gHeartbeatDur) } // old code //cmd := exec.Command("/bin/sh", "-c", "ulimit -S -c 0 >/dev/null 2>&1 ; /usr/sbin/rabbitmq-server") //cmd.Env = append(os.Environ(), // fmt.Sprintf("RABBITMQ_NODE_IP_ADDRESS=%s", gIp), // fmt.Sprintf("RABBITMQ_NODE_PORT=%d", gPort), //) //if err := cmd.Start(); err != nil { // glog.Errorf("start rabbitmq error: %v", err) // return //} //pid := cmd.Process.Pid //// Sleep before register rmq to zk to wait rmq listening on its server socket //time.Sleep(3 * time.Second) //InitZK(strings.Split(*zks, ","), *zkRoot) //quitCh := make(chan struct{}) //go func() { // defer close(quitCh) // glog.Infof("Waiting on process pid: %d", pid) // err := cmd.Wait() // if err != nil { // glog.Errorf("Wait rabbitmq process %d error: %v", pid, err) // return // } // glog.Info("Rabbitmq quit:", cmd.ProcessState) //}() //// quit would clear zk automatically //handleSignal(quitCh, func() { // glog.Info("Closed on signal") //}) //CloseZK() }