本文整理汇总了Golang中github.com/Sirupsen/logrus.Fatalln函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalln函数的具体用法?Golang Fatalln怎么用?Golang Fatalln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatalln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runShell
func runShell(version string) {
if os.Getenv("GOBU") != "" {
log.Fatalln("Already in boostraped env!")
}
os.Setenv("GOBU", "1")
log.Println(">> You are now in a new GOBU shell. To exit, type 'exit'")
shell := os.Getenv("SHELL")
if runtime.GOOS == "windows" {
parentID := os.Getppid()
parentProcess, err := ps.FindProcess(parentID)
if err != nil {
log.Fatalln(err)
}
shell = parentProcess.Executable()
}
shellBinary := resolveBinary(shell)
run(version, shellBinary, []string{shellBinary})
log.Println("Exited gobu shell")
}
示例2: destroy
func destroy(c *cli.Context) {
log.Infoln("Destroy")
additionalEnvs, err := config.CreateEnvItemsModelFromSlice(MachineParamsAdditionalEnvs.Get())
if err != nil {
log.Fatalf("Invalid Environment parameter: %s", err)
}
configModel, err := config.ReadMachineConfigFileFromDir(MachineWorkdir.Get(), additionalEnvs)
if err != nil {
log.Fatalln("Failed to read Config file: ", err)
}
isOK, err := pathutil.IsPathExists(path.Join(MachineWorkdir.Get(), "Vagrantfile"))
if err != nil {
log.Fatalln("Failed to check 'Vagrantfile' in the WorkDir: ", err)
}
if !isOK {
log.Fatalln("Vagrantfile not found in the WorkDir!")
}
log.Infof("configModel: %#v", configModel)
if err := doCleanup(configModel, "will-be-destroyed"); err != nil {
log.Fatalf("Failed to Cleanup: %s", err)
}
if err := doDestroy(configModel); err != nil {
log.Fatalf("Failed to Destroy: %s", err)
}
log.Infoln("=> Destroy DONE - OK")
}
示例3: OnDisconnect
// OnDisconnect event. Terminates MumbleDJ process or retries connection if
// automatic connection retries are enabled.
func (dj *MumbleDJ) OnDisconnect(e *gumble.DisconnectEvent) {
dj.Queue.Reset()
if viper.GetBool("connection.retry_enabled") &&
(e.Type == gumble.DisconnectError || e.Type == gumble.DisconnectKicked) {
logrus.WithFields(logrus.Fields{
"interval_secs": fmt.Sprintf("%d", viper.GetInt("connection.retry_interval")),
"attempts": fmt.Sprintf("%d", viper.GetInt("connection.retry_attempts")),
}).Warnln("Disconnected from server. Retrying connection...")
success := false
for retries := 0; retries < viper.GetInt("connection.retry_attempts"); retries++ {
logrus.Infoln("Retrying connection...")
if client, err := gumble.DialWithDialer(new(net.Dialer), viper.GetString("connection.address")+":"+viper.GetString("connection.port"), dj.GumbleConfig, dj.TLSConfig); err == nil {
dj.Client = client
logrus.Infoln("Successfully reconnected to the server!")
success = true
break
}
time.Sleep(time.Duration(viper.GetInt("connection.retry_interval")) * time.Second)
}
if !success {
dj.KeepAlive <- true
logrus.Fatalln("Could not reconnect to server. Exiting...")
}
} else {
dj.KeepAlive <- true
logrus.Fatalln("Disconnected from server. No reconnect attempts will be made.")
}
}
示例4: launchSyndicates
func (rs *RingSyndicates) launchSyndicates(k int) {
rs.Syndics[k].Lock()
defer rs.waitGroup.Done()
rs.waitGroup.Add(1)
l, err := net.Listen("tcp", fmt.Sprintf(":%d", rs.Syndics[k].config.Port))
if err != nil {
log.Fatalln(err)
return
}
var opts []grpc.ServerOption
creds, err := credentials.NewServerTLSFromFile(rs.Syndics[k].config.CertFile, rs.Syndics[k].config.KeyFile)
if err != nil {
log.Fatalln("Error load cert or key:", err)
}
opts = []grpc.ServerOption{grpc.Creds(creds)}
rs.Syndics[k].gs = grpc.NewServer(opts...)
if rs.Syndics[k].config.Master {
pb.RegisterSyndicateServer(rs.Syndics[k].gs, rs.Syndics[k].server)
log.Println("Master starting up on", rs.Syndics[k].config.Port)
rs.Syndics[k].gs.Serve(l)
} else {
//pb.RegisterRingDistServer(s, newRingDistServer())
//log.Printf("Starting ring slave up on %d...\n", cfg.Port)
//s.Serve(l)
log.Fatalln("Syndicate slaves not implemented yet")
}
rs.Syndics[k].Unlock()
}
示例5: Execute
func (c *ArtifactsDownloaderCommand) Execute(context *cli.Context) {
formatter.SetRunnerFormatter()
if len(c.URL) == 0 || len(c.Token) == 0 {
logrus.Fatalln("Missing runner credentials")
}
if c.ID <= 0 {
logrus.Fatalln("Missing build ID")
}
// Create temporary file
file, err := ioutil.TempFile("", "artifacts")
if err != nil {
logrus.Fatalln(err)
}
file.Close()
defer os.Remove(file.Name())
// Download artifacts file
err = c.doRetry(func() (bool, error) {
return c.download(file.Name())
})
if err != nil {
logrus.Fatalln(err)
}
// Extract artifacts file
err = archives.ExtractZipFile(file.Name())
if err != nil {
logrus.Fatalln(err)
}
}
示例6: main
func main() {
flag.Parse()
cpus := runtime.NumCPU()
runtime.GOMAXPROCS(cpus)
log.SetFormatter(&log.JSONFormatter{})
log.SetOutput(os.Stderr)
if *env == "production" {
log.SetLevel(log.WarnLevel)
} else {
log.SetLevel(log.DebugLevel)
}
log.Infoln("Starting server...")
// load config
d, err := ioutil.ReadFile(*configFile)
if err != nil {
log.Fatalln("[ERROR] read config.yml", err)
}
cfg, err := config.Load(bytes.NewReader(d), *env)
if err != nil {
log.Fatalln("[ERROR] config Load", err)
}
psAll := sphinx.NewSphinx(cfg.PSConfig, cpus)
ctx := context.Background()
ctx = sphinx.NewContext(ctx, psAll)
kami.Context = ctx
kami.Serve()
}
示例7: Chain
func (p *Client) Chain() []byte {
certs := make([][]byte, len(chainURLs))
var wg sync.WaitGroup
for i, url := range chainURLs {
wg.Add(1)
go func(i int, url string) {
defer wg.Done()
resp, err := http.Get(url)
if err != nil {
log.Fatalln(err)
return
}
defer resp.Body.Close()
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
return
}
certs[i] = data
}(i, url)
}
wg.Wait()
result := make([]byte, 0, 1024*1024)
for _, data := range certs {
result = append(result, data...)
if result[len(result)-1] != 10 {
result = append(result, 10)
}
}
return result
}
示例8: NewDBSession
//NewDBSession creates a new session to manage database data
func NewDBSession(database string) *r.Session {
conn, err := r.Connect(r.ConnectOpts{
Address: GetKeyValue("database", "address"),
Database: database,
MaxOpen: 40,
})
if err != nil {
log.Fatalln(err)
return nil
}
log.Infof("Connected to RethinkDB %s", GetKeyValue("database", "address"))
status, err := createDB(database, conn)
if err != nil {
log.Fatalln(err)
} else {
log.Info(status)
}
tables := []string{"Trip", "Place", "User"}
total, err := createTables(database, tables, conn)
if err != nil {
log.Fatalln(err)
} else {
log.Infof("%d new table(s) created", total)
}
return conn
}
示例9: waitForInterrupts
func waitForInterrupts(finished *bool, abortSignal chan os.Signal, doneSignal chan int) {
signals := make(chan os.Signal)
signal.Notify(signals, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
interrupt := <-signals
if finished != nil {
*finished = true
}
// request stop, but wait for force exit
for interrupt == syscall.SIGQUIT {
log.Warningln("Requested quit, waiting for builds to finish")
interrupt = <-signals
}
log.Warningln("Requested exit:", interrupt)
go func() {
for {
abortSignal <- interrupt
}
}()
select {
case newSignal := <-signals:
log.Fatalln("forced exit:", newSignal)
case <-time.After(common.ShutdownTimeout * time.Second):
log.Fatalln("shutdown timedout")
case <-doneSignal:
}
}
示例10: open
// open opens a new database connection with the specified
// driver and connection string and returns a store.
func open(driver, config string) *sql.DB {
db, err := sql.Open(driver, config)
if err != nil {
logrus.Errorln(err)
logrus.Fatalln("database connection failed")
}
if driver == "mysql" {
// per issue https://github.com/go-sql-driver/mysql/issues/257
db.SetMaxIdleConns(0)
}
setupMeddler(driver)
if err := pingDatabase(db); err != nil {
logrus.Errorln(err)
logrus.Fatalln("database ping attempts failed")
}
if err := setupDatabase(driver, db); err != nil {
logrus.Errorln(err)
logrus.Fatalln("migration failed")
}
cleanupDatabase(db)
return db
}
示例11: Execute
func (c *UnregisterCommand) Execute(context *cli.Context) {
if !common.DeleteRunner(c.URL, c.Token) {
log.Fatalln("Failed to delete runner")
}
err := c.loadConfig()
if err != nil {
log.Warningln(err)
return
}
runners := []*common.RunnerConfig{}
for _, otherRunner := range c.config.Runners {
if otherRunner.RunnerCredentials == c.RunnerCredentials {
continue
}
runners = append(runners, otherRunner)
}
// check if anything changed
if len(c.config.Runners) == len(runners) {
return
}
c.config.Runners = runners
// save config file
err = c.saveConfig()
if err != nil {
log.Fatalln("Failed to update", c.ConfigFile, err)
}
log.Println("Updated", c.ConfigFile)
}
示例12: Execute
func (c *ArchiveCommand) Execute(context *cli.Context) {
logrus.SetFormatter(
&logrus.TextFormatter{
ForceColors: true,
DisableTimestamp: false,
},
)
wd, err := os.Getwd()
if err != nil {
logrus.Fatalln("Failed to get current working directory:", err)
}
if c.Output == "" {
logrus.Fatalln("Missing archive file name!")
}
c.wd = wd
c.files = make(map[string]os.FileInfo)
c.processPaths()
c.processUntracked()
ai, err := os.Stat(c.Output)
if err != nil && !os.IsNotExist(err) {
logrus.Fatalln("Failed to verify archive:", c.Output, err)
}
if ai != nil {
if !c.isChanged(ai.ModTime()) {
logrus.Infoln("Archive is up to date!")
return
}
}
c.archive()
}
示例13: Execute
func (c *RunCommand) Execute(context *cli.Context) {
svcConfig := &service.Config{
Name: c.ServiceName,
DisplayName: c.ServiceName,
Description: defaultDescription,
Arguments: []string{"run"},
}
service, err := service_helpers.New(c, svcConfig)
if err != nil {
log.Fatalln(err)
}
if c.Syslog {
logger, err := service.SystemLogger(nil)
if err == nil {
log.AddHook(&ServiceLogHook{logger})
} else {
log.Errorln(err)
}
}
err = service.Run()
if err != nil {
log.Fatalln(err)
}
}
示例14: doSetup
func doSetup(c *cli.Context) {
PrintBitriseHeaderASCIIArt()
log.Infoln("[BITRISE_CLI] - Setup")
log.Infoln("Detected OS:", runtime.GOOS)
switch runtime.GOOS {
case "darwin":
if err := doSetupOnOSX(); err != nil {
log.Fatalln("Setup failed:", err)
}
case "linux":
if err := doSetupOnLinux(); err != nil {
log.Fatalln("Setup failed:", err)
}
default:
log.Fatalln("Sorry, unsupported platform :(")
}
// guide
fmt.Println()
log.Infoln("We're ready to rock!!")
fmt.Println()
log.Infoln("To start using bitrise:")
log.Infoln("* cd into your project's directory (if you're not there already)")
log.Infoln("* call: bitrise init")
log.Infoln("* follow the guide")
fmt.Println()
log.Infoln("That's all :)")
}
示例15: Execute
func (c *VerifyCommand) Execute(context *cli.Context) {
userModeWarning(true)
err := c.loadConfig()
if err != nil {
log.Fatalln(err)
return
}
// verify if runner exist
runners := []*common.RunnerConfig{}
for _, runner := range c.config.Runners {
if c.network.VerifyRunner(runner.RunnerCredentials) {
runners = append(runners, runner)
}
}
if !c.DeleteNonExisting {
return
}
// check if anything changed
if len(c.config.Runners) == len(runners) {
return
}
c.config.Runners = runners
// save config file
err = c.saveConfig()
if err != nil {
log.Fatalln("Failed to update", c.ConfigFile, err)
}
log.Println("Updated", c.ConfigFile)
}