• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang log.Fatal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/skynetservices/skynet/log.Fatal函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatal函数的具体用法?Golang Fatal怎么用?Golang Fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Fatal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: updateCode

// Checkout project from repository
func (b *builder) updateCode() {
	p, err := b.scm.ImportPathFromRepo(b.BuildConfig.AppRepo)
	b.projectPath = path.Join(b.BuildConfig.Jail, "src", p)

	if err != nil {
		log.Fatal(err.Error())
	}

	out, err := b.term.Exec("ls " + b.projectPath)

	if err != nil {
		fmt.Println("Creating project directories")
		out, err = b.term.Exec("mkdir -p " + b.projectPath)

		if err != nil {
			log.Fatal("Could not create project directories")
		}

		fmt.Println(string(out))
	}

	// Fetch code base
	b.scm.SetTerminal(b.term)
	b.scm.Checkout(b.BuildConfig.AppRepo, b.BuildConfig.RepoBranch, b.projectPath)
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:26,代码来源:builder.go


示例2: validatePackage

func (b *builder) validatePackage() {
	// Validate this package is a command
	var err error
	b.pack, err = context.ImportDir(".", 0)

	if err != nil {
		log.Fatal("Could not import package for validation")
	}

	if !b.pack.IsCommand() {
		log.Fatal("Package is not a command")
	}
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:13,代码来源:builder.go


示例3: listen

func (s *Service) listen(addr skynet.BindAddr, bindWait *sync.WaitGroup) {
	var err error
	s.rpcListener, err = addr.Listen()
	if err != nil {
		log.Fatal(err)
	}

	log.Printf(log.INFO, "%+v\n", ServiceListening{
		Addr:        &addr,
		ServiceInfo: s.ServiceInfo,
	})

	// We may have changed port due to conflict, ensure config has the correct port now
	a, _ := skynet.BindAddrFromString(addr.String())
	s.ServiceAddr.IPAddress = a.IPAddress
	s.ServiceAddr.Port = a.Port

	bindWait.Done()

	for {
		conn, err := s.rpcListener.AcceptTCP()

		if s.shuttingDown {
			break
		}

		if err != nil && !s.shuttingDown {
			log.Println(log.ERROR, "AcceptTCP failed", err)
			continue
		}
		s.connectionChan <- conn
	}
}
开发者ID:bubble66,项目名称:skynet,代码行数:33,代码来源:service.go


示例4: init

func init() {
	flagset := flag.NewFlagSet("config", flag.ContinueOnError)
	flagset.StringVar(&configFile, "config", "", "Config File")
	flagset.StringVar(&uuid, "uuid", "", "uuid")

	args, _ := SplitFlagsetFromArgs(flagset, os.Args[1:])
	flagset.Parse(args)

	// Ensure we have a UUID
	if uuid == "" {
		uuid = NewUUID()
	}

	if configFile == "" {
		for _, f := range defaultConfigFiles {
			if _, err := os.Stat(f); err == nil {
				configFile = f
				break
			}
		}
	}

	if configFile == "" {
		log.Println(log.ERROR, "Failed to find config file")
		conf = config.NewDefault()
		return
	}

	if _, err := os.Stat(configFile); os.IsNotExist(err) {
		log.Println(log.ERROR, "Config file does not exist", err)
		conf = config.NewDefault()
		return
	}

	var err error
	if conf, err = config.ReadDefault(configFile); err != nil {
		conf = config.NewDefault()
		log.Fatal(err)
	}

	// Set default log level from config, this can be overriden at the service level when the service is created
	if l, err := conf.RawStringDefault("log.level"); err == nil {
		log.SetLogLevel(log.LevelFromString(l))
	}

	// Set default log level from config, this can be overriden at the service level when the service is created
	if lh, err := conf.RawStringDefault("log.sysloghost"); err == nil {
		log.SetSyslogHost(lh)
	}

	// Set syslog port
	if i, err := conf.Int("DEFAULT", "log.syslogport"); err == nil {
		log.SetSyslogPort(i)
	}

	// Set GOMAXPROCS
	if i, err := conf.Int("DEFAULT", "runtime.gomaxprocs"); err == nil {
		runtime.GOMAXPROCS(i)
	}
}
开发者ID:bubble66,项目名称:skynet,代码行数:60,代码来源:config.go


示例5: ExecPath

func (c *SSHConn) ExecPath(cmd, path string) (out []byte, err error) {
	var session *ssh.Session

	session, err = c.client.NewSession()
	if err != nil {
		log.Fatal("Failed to create session: " + err.Error())
	}
	defer session.Close()

	envVars := ""
	if c.env != nil {
		for name, value := range c.env {
			envVars = envVars + name + "=\"" + value + "\" "
			/*
				      TODO: This should be the proper way to set the environment, but fails for some reason
							       * Investigate why and possibly send pull-request to maintainer
										err = session.Setenv(name, value)

										if err != nil {
											log.Fatal("Failed to set environment: " + err.Error())
										}
			*/
		}
	}

	cmd = envVars + cmd

	if path != "" {
		cmd = "cd " + path + " && " + cmd
	}

	return session.CombinedOutput(cmd)
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:33,代码来源:ssh.go


示例6: SetLogLevel

func SetLogLevel(criteria *skynet.Criteria, level string) {
	instances, err := skynet.GetServiceManager().ListInstances(criteria)

	if err != nil {
		log.Fatal(err)
	}

	var wait sync.WaitGroup

	for _, instance := range filterDaemon(instances) {
		wait.Add(1)
		go func(instance skynet.ServiceInfo) {
			fmt.Println("Setting LogLevel to " + level + " for: " + instance.UUID)
			d := daemon.GetDaemonForService(&instance)

			in := daemon.SubServiceLogLevelRequest{
				UUID:  instance.UUID,
				Level: level,
			}
			out, err := d.SubServiceLogLevel(in)

			if err != nil {
				fmt.Println("Returned Error: " + err.Error())
				wait.Done()
				return
			}

			logLevelTemplate.Execute(os.Stdout, out)
			wait.Done()
		}(instance)
	}

	wait.Wait()
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:34,代码来源:admin.go


示例7: main

// Daemon will run and maintain skynet services.
//
// Daemon will run the "SkynetDeployment" service, which can be used
// to remotely spawn new services on the host.
func main() {
	si := skynet.NewServiceInfo("SkynetDaemon", "2.0.0")
	deployment := NewSkynetDaemon()

	s := service.CreateService(deployment, si)

	deployment.Service = s

	// handle panic so that we remove ourselves from the pool in case of catastrophic failure
	defer func() {
		s.Shutdown()
		deployment.closeStateFile()

		if err := recover(); err != nil {
			e := err.(error)
			log.Fatal("Unrecovered error occured: " + e.Error())
		}
	}()

	// Collect Host metrics
	statTicker := time.Tick((5 * time.Second))
	go func() {
		for _ = range statTicker {
			deployment.updateHostStats(si.ServiceAddr.IPAddress)
		}
	}()

	// If we pass false here service will not be Registered
	// we could do other work/tasks by implementing the Started method and calling Register() when we're ready
	s.Start().Wait()
}
开发者ID:carriercomm,项目名称:skynetd,代码行数:35,代码来源:main.go


示例8: GetServiceManager

func GetServiceManager() ServiceManager {
	if manager == nil {
		log.Fatal("No ServiceManager provided")
	}

	return manager
}
开发者ID:CowLeo,项目名称:skynet-1,代码行数:7,代码来源:servicemanager.go


示例9: StopDaemon

func StopDaemon(criteria *skynet.Criteria) {
	hosts, err := skynet.GetServiceManager().ListHosts(criteria)

	if err != nil {
		log.Fatal(err)
	}

	var wait sync.WaitGroup

	for _, host := range hosts {
		wait.Add(1)
		go func(host string) {
			d := daemon.GetDaemonForHost(host)

			in := daemon.StopRequest{}
			out, err := d.Stop(in)

			if err != nil {
				fmt.Println("Returned Error: " + err.Error())
				wait.Done()
				return
			}

			if out.Ok {
				fmt.Printf("Daemon stopped on host: %v\n", host)
			} else {
				fmt.Printf("Failed to stop daemon on host: %v\n", host)
			}

			wait.Done()
		}(host)
	}

	wait.Wait()
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:35,代码来源:admin.go


示例10: Stop

func Stop(criteria *skynet.Criteria) {
	instances, err := skynet.GetServiceManager().ListInstances(criteria)

	if err != nil {
		log.Fatal(err)
	}

	var wait sync.WaitGroup

	for _, instance := range filterDaemon(instances) {
		wait.Add(1)
		go func(instance skynet.ServiceInfo) {
			fmt.Println("Stopping: " + instance.UUID)
			d := daemon.GetDaemonForService(&instance)

			in := daemon.StopSubServiceRequest{
				UUID: instance.UUID,
			}
			out, err := d.StopSubService(in)

			if err != nil {
				fmt.Println("Returned Error: " + err.Error())
				wait.Done()
				return
			}

			stopTemplate.Execute(os.Stdout, out)
			wait.Done()
		}(instance)
	}

	wait.Wait()
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:33,代码来源:admin.go


示例11: getInstances

func getInstances(c *skynet.Criteria) []skynet.ServiceInfo {
	instances, err := skynet.GetServiceManager().ListInstances(c)

	if err != nil {
		log.Fatal(err)
	}

	return instances
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:9,代码来源:sky.go


示例12: getServices

func getServices(c *skynet.Criteria) []string {
	services, err := skynet.GetServiceManager().ListServices(c)

	if err != nil {
		log.Fatal(err)
	}

	return services
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:9,代码来源:sky.go


示例13: getVersions

func getVersions(c *skynet.Criteria) []string {
	versions, err := skynet.GetServiceManager().ListVersions(c)

	if err != nil {
		log.Fatal(err)
	}

	return versions
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:9,代码来源:sky.go


示例14: setupScm

func (b *builder) setupScm() {
	switch b.BuildConfig.RepoType {
	case "git":
		b.scm = new(GitScm)

	default:
		log.Fatal("unkown RepoType")
	}
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:9,代码来源:builder.go


示例15: getHosts

func getHosts(c *skynet.Criteria) []string {
	hosts, err := skynet.GetServiceManager().ListHosts(c)

	if err != nil {
		log.Fatal(err)
	}

	return hosts
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:9,代码来源:sky.go


示例16: NewUUID

// NewUUID() provides unique identifier strings.
func NewUUID() string {
	b := make([]byte, 16)
	_, err := io.ReadFull(rand.Reader, b)
	if err != nil {
		log.Fatal(err)
	}
	b[6] = (b[6] & 0x0F) | 0x40
	b[8] = (b[8] &^ 0x40) | 0x80
	return fmt.Sprintf("%x-%x-%x-%x-%x", b[:4], b[4:6], b[6:8], b[8:10], b[10:])
}
开发者ID:CowLeo,项目名称:skynet-1,代码行数:11,代码来源:uuid.go


示例17: runCommands

func (b *builder) runCommands(cmds []string) {
	for _, cmd := range cmds {
		out, err := b.term.Exec(cmd)
		fmt.Println(string(out))

		if err != nil {
			log.Fatal("Failed to execute dependent command: " + cmd + "\n" + err.Error())
		}
	}
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:10,代码来源:builder.go


示例18: testSkynet

func (b *builder) testSkynet() {
	fmt.Println("Testing Skynet")
	p := path.Join(b.BuildConfig.Jail, "src/github.com/skynetservices/skynet")

	b.getPackageDependencies(p)

	out, err := b.term.ExecPath(b.BuildConfig.GoRoot+"/bin/go test ./...", p)
	fmt.Println(string(out))

	if err != nil {
		log.Fatal("Failed tests: " + err.Error())
	}
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:13,代码来源:builder.go


示例19: newBuilder

func newBuilder(config string) *builder {
	if config == "" {
		config = "./build.cfg"
	}

	f, err := ioutil.ReadFile(config)

	if err != nil {
		log.Fatal("Failed to read: " + config)
	}

	b := new(builder)

	err = json.Unmarshal(f, b)

	if err != nil {
		log.Fatal("Failed to parse " + config + ": " + err.Error())
	}

	if isHostLocal(b.BuildConfig.Host) {
		fmt.Println("Connecting to build machine: " + b.BuildConfig.Host)
		b.term = new(LocalTerminal)
	} else {
		sshClient := new(SSHConn)
		b.term = sshClient
		fmt.Println("Connecting to build machine: " + b.BuildConfig.Host)
		err = sshClient.Connect(b.BuildConfig.Host, b.BuildConfig.User)

		if err != nil {
			log.Fatal("Failed to connect to build machine: " + err.Error())
		}
	}

	b.validatePackage()

	return b
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:37,代码来源:builder.go


示例20: getPackageDependencies

func (b *builder) getPackageDependencies(p string) {
	flags := []string{"-d"}

	if b.BuildConfig.UpdatePackages {
		flags = append(flags, "-u")
	}

	fmt.Println("Fetching dependencies")
	out, err := b.term.ExecPath(b.BuildConfig.GoRoot+"/bin/go get "+strings.Join(flags, " ")+" ./...", p)
	fmt.Println(string(out))

	if err != nil {
		log.Fatal("Failed to fetch dependencies\n" + err.Error())
	}
}
开发者ID:carriercomm,项目名称:sky-1,代码行数:15,代码来源:builder.go



注:本文中的github.com/skynetservices/skynet/log.Fatal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log.Println函数代码示例发布时间:2022-05-28
下一篇:
Golang skynet.Query类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap