本文整理匯總了Golang中github.com/golang/glog.Exit函數的典型用法代碼示例。如果您正苦於以下問題:Golang Exit函數的具體用法?Golang Exit怎麽用?Golang Exit使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Exit函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
// 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.")
}
示例2: Set
// Required interface for flag.Var
func (config *Config) Set(runonceConfig string) error {
_, err := os.Stat(runonceConfig)
if err != nil {
log.Exit("missing config file: ", err.Error())
}
configData, err := ioutil.ReadFile(runonceConfig)
if err != nil {
log.Exit("failed to read config file: ", err.Error())
}
return json.Unmarshal([]byte(configData), config)
}
示例3: main
func main() {
flag.Parse()
log.Infof("Simulating %v clients.", *count)
for i := 0; i < *count; i++ {
id := uuid.New()
log.Infof("client %v with id %v", i, id)
client, err := doorman.NewWithID(*addr, id, doorman.DialOpts(grpc.WithInsecure()))
if err != nil {
log.Exit(err)
}
defer client.Close()
res, err := client.Resource(*resource, *initialCapacity)
if err != nil {
log.Exit(err)
}
go manipulateCapacity(res, *initialCapacity, id)
conn, err := grpc.Dial(*target, grpc.WithInsecure())
if err != nil {
log.Exitf("did not connect: %v", err)
}
defer conn.Close()
c := pb.NewGreeterClient(conn)
rl := ratelimiter.NewQPS(res)
for i := 0; i < *workers; i++ {
go func() {
ctx := context.Background()
for {
if err := rl.Wait(ctx); err != nil {
log.Exitf("rl.Wait: %v", err)
}
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
if _, err := c.SayHello(ctx, &pb.HelloRequest{Name: *resource}); err != nil {
log.Error(err)
}
cancel()
}
}()
}
}
http.Handle("/metrics", prometheus.Handler())
http.ListenAndServe(fmt.Sprintf(":%v", *port), nil)
}
示例4: main
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)
}
}
示例5: main
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)
}
}
示例6: main
func main() {
flag.Parse()
domain, err := tao.LoadDomain(*configPath, []byte(*domainPass))
if err != nil {
glog.Exitf("Couldn't load the config path %s: %s\n", *configPath, err)
return
}
sock, err := net.Listen(*network, *addr)
if err != nil {
glog.Exit("Couldn't bind socket to address:", err)
return
}
fmt.Println("tcca: accepting connections")
for {
conn, err := sock.Accept()
if err != nil {
glog.Exitf("Couldn't accept a connection on %s: %s", *addr, err)
return
}
go tao.HandleCARequest(conn, domain.Keys.SigningKey, domain.Guard)
}
}
示例7: main
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)
}
}
示例8: main
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)
}
}
示例9: main
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)
}
}
示例10: main
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)
}
}
示例11: main
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)
}
}
示例12: main
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)
}
}
示例13: main
func main() {
defer glog.Flush()
glog.CopyStandardLogTo("info")
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
if err := do(); err != nil {
glog.Exit(err)
}
}
示例14: parseIP
func parseIP(address string) net.IP {
addr, err := net.LookupIP(address)
if err != nil {
log.Exit(err)
}
if len(addr) < 1 {
log.Exitf("failed to parse IP from address '%v'", address)
}
return addr[0]
}
示例15: main
func main() {
flag.Parse()
if *server == "" || *resource == "" {
log.Exit("both --server and --resource must be specified")
}
if *clientID == "" {
log.Exit("--client_id must be set")
}
var opts []grpc.DialOption
if len(*caFile) != 0 {
var creds credentials.TransportAuthenticator
var err error
creds, err = credentials.NewClientTLSFromFile(*caFile, "")
if err != nil {
log.Exitf("Failed to create TLS credentials %v", err)
}
opts = append(opts, grpc.WithTransportCredentials(creds))
} else {
opts = append(opts, grpc.WithInsecure())
}
client, err := doorman.NewWithID(*server, *clientID, doorman.DialOpts(opts...))
if err != nil {
log.Exitf("could not create client: %v", err)
}
defer client.Close()
resource, err := client.Resource(*resource, *wants)
if err != nil {
log.Exitf("could not acquire resource: %v", err)
}
fmt.Println(<-resource.Capacity())
}