本文整理汇总了Golang中github.com/Sirupsen/logrus.Fatalf函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalf函数的具体用法?Golang Fatalf怎么用?Golang Fatalf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatalf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: RemoveVlan
// Remove a vlan
func (self *Vxlan) RemoveVlan(vlanId uint16, vni uint32) error {
vlan := self.vlanDb[vlanId]
if vlan == nil {
log.Fatalf("Could not find the vlan %d", vlanId)
}
// Make sure the flood lists are empty
if vlan.localFlood.NumOutput() != 0 {
log.Fatalf("VLAN flood list is not empty")
}
log.Infof("Deleting vxlan: %d, vlan: %d", vni, vlanId)
// Uninstall the flood lists
vlan.allFlood.Delete()
vlan.localFlood.Delete()
// Uninstall mac miss Entries
vlan.localMacMiss.Delete()
vlan.vtepMacMiss.Delete()
// uninstall vtep vlan mapping flows
for _, portVlanFlow := range vlan.vtepVlanFlowDb {
portVlanFlow.Delete()
}
// Remove it from DB
delete(self.vlanDb, vlanId)
return nil
}
开发者ID:rtrentin73,项目名称:netplugin,代码行数:32,代码来源:vxlanBridge.go
示例2: enable
func enable(c *cli.Context) {
changed := false
cfg, err := config.LoadConfig()
if err != nil {
log.Fatal(err)
}
for _, service := range c.Args() {
if val, ok := cfg.Rancher.ServicesInclude[service]; !ok || !val {
if strings.HasPrefix(service, "/") && !strings.HasPrefix(service, "/var/lib/rancher/conf") {
log.Fatalf("ERROR: Service should be in path /var/lib/rancher/conf")
}
if _, err := compose.LoadServiceResource(service, true, cfg); err != nil {
log.Fatalf("could not load service %s", service)
}
cfg.Rancher.ServicesInclude[service] = true
changed = true
}
}
if changed {
if err := cfg.Set("rancher.services_include", cfg.Rancher.ServicesInclude); err != nil {
log.Fatal(err)
}
}
}
开发者ID:rowhit,项目名称:os,代码行数:26,代码来源:service.go
示例3: join
func join(c *cli.Context) {
dflag := getDiscovery(c)
if dflag == "" {
log.Fatalf("discovery required to join a cluster. See '%s join --help'.", c.App.Name)
}
addr := c.String("advertise")
if addr == "" {
log.Fatal("missing mandatory --advertise flag")
}
if !checkAddrFormat(addr) {
log.Fatal("--advertise should be of the form ip:port or hostname:port")
}
joinDelay, err := time.ParseDuration(c.String("delay"))
if err != nil {
log.Fatalf("invalid --delay: %v", err)
}
if joinDelay < time.Duration(0)*time.Second {
log.Fatalf("--delay should not be a negative number")
}
hb, err := time.ParseDuration(c.String("heartbeat"))
if err != nil {
log.Fatalf("invalid --heartbeat: %v", err)
}
if hb < 1*time.Second {
log.Fatal("--heartbeat should be at least one second")
}
ttl, err := time.ParseDuration(c.String("ttl"))
if err != nil {
log.Fatalf("invalid --ttl: %v", err)
}
if ttl <= hb {
log.Fatal("--ttl must be strictly superior to the heartbeat value")
}
d, err := discovery.New(dflag, hb, ttl, getDiscoveryOpt(c))
if err != nil {
log.Fatal(err)
}
// if joinDelay is 0, no delay will be executed
// if joinDelay is larger than 0,
// add a random delay between 0s and joinDelay at start to avoid synchronized registration
if joinDelay > 0 {
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
delay := time.Duration(r.Int63n(int64(joinDelay)))
log.Infof("Add a random delay %s to avoid synchronized registration", delay)
time.Sleep(delay)
}
for {
log.WithFields(log.Fields{"addr": addr, "discovery": dflag}).Infof("Registering on the discovery service every %s...", hb)
if err := d.Register(addr); err != nil {
log.Error(err)
}
time.Sleep(hb)
}
}
开发者ID:yehohanan7,项目名称:swarm,代码行数:60,代码来源:join.go
示例4: delete
func delete(serviceName string, etcdPath string) error {
log.Infoln("cli.delete():Start Delete")
client, err := etcdclient.NewEtcdClient(etcdPath)
if err != nil {
log.Fatalf("cli.delete():%+v\n", err)
fmt.Printf("[error]cli.delete():%+v\n", err)
return err
}
//quary service
s, err := client.GetService(serviceName)
if err != nil {
log.Fatalf("cli.delete():%+v\n", err)
fmt.Printf("[error]cli.delete():%+v\n", err)
return err
}
//delete from etcd
err = client.DeleteService(serviceName)
if err != nil {
log.Fatalf("cli.delete():%+v\n", err)
fmt.Printf("[error]cli.delete():%+v\n", err)
}
//delete from swarm
err = service.DeleteService(s)
if err != nil {
log.Fatalf("cli.delete():%+v\n", err)
fmt.Printf("[error]cli.delete():%+v\n", err)
return err
}
return nil
}
开发者ID:yansmallb,项目名称:tycoon-go,代码行数:33,代码来源:delete.go
示例5: registerService
func (d *daemon) registerService() {
// Create an objdb client
objdbClient := client.NewClient()
// Get the address to be used for local communication
localIP, err := objdbClient.GetLocalAddr()
if err != nil {
log.Fatalf("Error getting locla IP address. Err: %v", err)
}
// service info
srvInfo := objdb.ServiceInfo{
ServiceName: "netmaster",
HostAddr: localIP,
Port: 9999,
}
// Register the node with service registry
err = objdbClient.RegisterService(srvInfo)
if err != nil {
log.Fatalf("Error registering service. Err: %v", err)
}
log.Infof("Registered netmaster service with registry")
}
开发者ID:ChengTiesheng,项目名称:netplugin,代码行数:25,代码来源:main.go
示例6: Show
//Show displays the details of an Account.
func Show(cmd *cli.Cmd) {
email := cmd.String(cli.StringArg{
Name: "EMAIL",
Desc: "email address",
HideValue: true,
})
cmd.Action = func() {
a := authorization.Account{
Email: *email,
}
account, resp, errs := a.ShowAcct()
if len(errs) > 0 {
log.Fatalf("Could not retrieve account: %s", errs[0])
}
if resp.StatusCode != 200 {
log.Fatalf("Could not retrieve account: %s", resp.Status)
}
printAccountDetail(account)
}
}
开发者ID:dubsquared,项目名称:kumoru-cli,代码行数:26,代码来源:accounts.go
示例7: discovery
func discovery() {
var err error
var opts []grpc.DialOption
if insecureDiscovery {
opts = append(opts, grpc.WithInsecure())
} else {
auth := credentials.NewClientTLSFromCert(nil, getServerName(discoveryServiceURL))
opts = append(opts, grpc.WithTransportCredentials(auth))
}
discoveryConn, err = grpc.Dial(discoveryServiceURL, opts...)
if err != nil {
logrus.Fatalf("grpc.go: error while connection to discovery service %v", err)
}
discoveryClient = pb.NewDiscoveryClient(discoveryConn)
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
res, err := discoveryClient.Get(ctx, &pb.DiscoveryRequest{
Environment: discoveryEnv,
SdkVersion: Version + "-otsimoctl",
OsName: runtime.GOOS,
})
if err != nil {
logrus.Fatalf("grpc:go: failed to get discovery config err=%v", err)
}
discoveryServices = res
}
开发者ID:otsimo,项目名称:otsimoctl,代码行数:26,代码来源:grpc.go
示例8: Archive
//Archive an Application
func Archive(cmd *cli.Cmd) {
uuid := cmd.String(cli.StringArg{
Name: "UUID",
Desc: "Application UUID",
HideValue: true,
})
cmd.Action = func() {
app := application.Application{
UUID: *uuid,
}
_, resp, errs := app.Delete()
if errs != nil {
log.Fatalf("Could not archive applications: %s", errs)
}
if resp.StatusCode != 202 {
log.Fatalf("Could not archive applications: %s", resp.Status)
}
fmt.Printf("Application %s accepted for archival\n", *uuid)
}
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:26,代码来源:applications.go
示例9: prepareServer
func (server *Server) prepareServer(router *mux.Router, entryPoint *EntryPoint, oldServer *manners.GracefulServer, middlewares ...negroni.Handler) (*manners.GracefulServer, error) {
log.Info("Preparing server")
// middlewares
var negroni = negroni.New()
for _, middleware := range middlewares {
negroni.Use(middleware)
}
negroni.UseHandler(router)
tlsConfig, err := server.createTLSConfig(entryPoint.TLS)
if err != nil {
log.Fatalf("Error creating TLS config %s", err)
return nil, err
}
if oldServer == nil {
return manners.NewWithServer(
&http.Server{
Addr: entryPoint.Address,
Handler: negroni,
TLSConfig: tlsConfig,
}), nil
}
gracefulServer, err := oldServer.HijackListener(&http.Server{
Addr: entryPoint.Address,
Handler: negroni,
TLSConfig: tlsConfig,
}, tlsConfig)
if err != nil {
log.Fatalf("Error hijacking server %s", err)
return nil, err
}
return gracefulServer, nil
}
开发者ID:tayzlor,项目名称:traefik,代码行数:33,代码来源:server.go
示例10: Action
func Action(c *cli.Context) {
args := append([]string{c.Command.Name}, c.Args()...)
if len(args) == 0 {
logrus.Fatalf("You need to use at least one filter")
}
chain, err := NewConverterChain(args)
if err != nil {
logrus.Fatalf("Failed to create a converter: %v", err)
}
input, err := ioutil.ReadAll(os.Stdin)
if err != nil {
logrus.Fatalf("Failed to read from stdin: %v", err)
}
conversionFunc, err := chain.ConversionFunc("[]byte", "interface{}")
if err != nil {
logrus.Fatalf("Failed to generate a conversion func: %v", err)
}
var output interface{}
if err = conversionFunc(input, &output); err != nil {
logrus.Fatalf("Failed to convert: %v", err)
}
fmt.Printf("%v\n", output)
}
开发者ID:moul,项目名称:converter,代码行数:28,代码来源:main.go
示例11: Show
//Show an Application.
func Show(cmd *cli.Cmd) {
uuid := cmd.String(cli.StringArg{
Name: "UUID",
Desc: "Application UUID",
HideValue: true,
})
cmd.Action = func() {
app := application.Application{
UUID: *uuid,
}
application, resp, errs := app.Show()
if errs != nil {
log.Fatalf("Could not retrieve application: %s", errs)
}
if resp.StatusCode != 200 {
log.Fatalf("Could not retrieve application: %s", resp.Status)
}
printAppDetail(application)
}
}
开发者ID:devx,项目名称:kumoru-sdk-go,代码行数:26,代码来源:applications.go
示例12: Run
// Run initializes the driver
func Run(ctx *cli.Context) {
gitRepoURL := fmt.Sprint(pluginPath, ctx.String("repo"))
if gitRepoURL == "" {
log.Fatalf("Exiting: A git URL is required to be used as a shared datastore for the endpoints")
}
log.Debugf("The plugin repo is [ %s ]", gitRepoURL)
gitPollInterval := ctx.Int("poll-interval")
if gitPollInterval == 0 {
gitPollInterval = control.DefaultInterval
}
log.Debugf("The git polling interval is [ %d ]", gitPollInterval)
var d ipvlan.Driver
var err error
if d, err = ipvlan.New(version, ctx); err != nil {
log.Fatalf("unable to create driver: %s", err)
}
// concatenate the absolute path to the spec file handle
absSocket := fmt.Sprint(pluginPath, ctx.String("socket"))
log.Info("IPVlan network driver initialized successfully")
log.Debugf("The plugin absolute path and handle is [ %s ]", absSocket)
if err := d.Listen(absSocket); err != nil {
log.Fatal(err)
}
}
开发者ID:nerdalert,项目名称:gitnet-overlay,代码行数:28,代码来源:main.go
示例13: registerService
// Register netplugin with service registry
func registerService(objdbClient objdb.ObjdbApi, opts cliOpts) error {
// Get the address to be used for local communication
localIP, err := objdbClient.GetLocalAddr()
if err != nil {
log.Fatalf("Error getting locla IP address. Err: %v", err)
return err
}
// service info
srvInfo := objdb.ServiceInfo{
ServiceName: "netplugin",
HostAddr: localIP,
Port: ofnet.OFNET_AGENT_PORT,
}
// Register the node with service registry
err = objdbClient.RegisterService(srvInfo)
if err != nil {
log.Fatalf("Error registering service. Err: %v", err)
return err
}
log.Infof("Registered netplugin service with registry")
return nil
}
开发者ID:syeduguri,项目名称:netplugin,代码行数:26,代码来源:cluster.go
示例14: configureSyslog
func configureSyslog(syslogParam string) {
var err error
var hook log.Hook
// disable colors if we're writing to syslog *and* we're the default text
// formatter, because the tty detection is useless here.
if tf, ok := log.StandardLogger().Formatter.(*log.TextFormatter); ok {
tf.DisableColors = true
}
if syslogParam == "kernel" {
hook, err = logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "netplugin")
if err != nil {
log.Fatalf("Could not connect to kernel syslog")
}
} else {
u, err := url.Parse(syslogParam)
if err != nil {
log.Fatalf("Could not parse syslog spec: %v", err)
}
hook, err = logrus_syslog.NewSyslogHook(u.Scheme, u.Host, syslog.LOG_INFO, "netplugin")
if err != nil {
log.Fatalf("Could not connect to syslog: %v", err)
}
}
log.AddHook(hook)
}
开发者ID:karamsivia,项目名称:netplugin,代码行数:29,代码来源:netd.go
示例15: pluginInstall
func pluginInstall(c *cli.Context) {
// Input validation
pluginSource := c.String("source")
if pluginSource == "" {
log.Fatalln("Missing required input: source")
}
pluginName := c.String("name")
if pluginName == "" {
log.Fatalf("Missing required input: name")
}
pluginType := c.String("type")
if pluginType == "" {
pluginType = plugins.TypeGeneric
}
// Install
log.Infof("=> Installing plugin (%s)...", plugins.PrintableName(pluginName, pluginType))
printableName, err := plugins.InstallPlugin(c.App.Version, pluginSource, pluginName, pluginType)
if err != nil {
log.Fatalf("Failed to install plugin, err: %s", err)
}
fmt.Println()
log.Infoln(colorstring.Greenf("Plugin (%s) installed", printableName))
}
开发者ID:birmacher,项目名称:bitrise,代码行数:26,代码来源:plugin_install.go
示例16: spawnGlobalDaemon
func spawnGlobalDaemon() {
if globalDaemon != nil {
log.Debugf("Global daemon already exists. Skipping.")
return
}
t := std_log.New(os.Stderr, "", 0)
eng := NewTestEngine(t)
globalEngine = eng
globalDaemon = mkDaemonFromEngine(eng, t)
// Spawn a Daemon
go func() {
log.Debugf("Spawning global daemon for integration tests")
listenURL := &url.URL{
Scheme: testDaemonProto,
Host: testDaemonAddr,
}
job := eng.Job("serveapi", listenURL.String())
job.SetenvBool("Logging", true)
if err := job.Run(); err != nil {
log.Fatalf("Unable to spawn the test daemon: %s", err)
}
}()
// Give some time to ListenAndServer to actually start
// FIXME: use inmem transports instead of tcp
time.Sleep(time.Second)
if err := eng.Job("acceptconnections").Run(); err != nil {
log.Fatalf("Unable to accept connections for test api: %s", err)
}
}
开发者ID:harshavardhana,项目名称:docker,代码行数:32,代码来源:runtime_test.go
示例17: ResetPassword
//ResetPassword requests the password reset operation to start.
func ResetPassword(cmd *cli.Cmd) {
email := cmd.String(cli.StringArg{
Name: "EMAIL",
Desc: "email address",
HideValue: true,
})
cmd.Action = func() {
a := authorization.Account{
Email: *email,
}
account, resp, errs := a.ResetPassword()
if len(errs) > 0 {
log.Fatalf("Could not retrieve account: %s", errs[0])
}
if resp.StatusCode != 204 {
log.Fatalf("Could not reset account password: %s", resp.Status)
}
fmt.Println("Password reset instructions sent to:", account.Email)
}
}
开发者ID:dubsquared,项目名称:kumoru-cli,代码行数:26,代码来源:accounts.go
示例18: ProjectPort
func ProjectPort(p *project.Project, c *cli.Context) {
if len(c.Args()) != 2 {
logrus.Fatalf("Please pass arguments in the form: SERVICE PORT")
}
index := c.Int("index")
protocol := c.String("protocol")
service, err := p.CreateService(c.Args()[0])
if err != nil {
logrus.Fatal(err)
}
containers, err := service.Containers()
if err != nil {
logrus.Fatal(err)
}
if index < 1 || index > len(containers) {
logrus.Fatalf("Invalid index %d", index)
}
output, err := containers[index-1].Port(fmt.Sprintf("%s/%s", c.Args()[1], protocol))
if err != nil {
logrus.Fatal(err)
}
fmt.Println(output)
}
开发者ID:aduermael,项目名称:libcompose,代码行数:28,代码来源:app.go
示例19: RemoveVlan
// Remove a vlan
func (self *Vxlan) RemoveVlan(vlanId uint16, vni uint32) error {
vlan := self.vlanDb[vlanId]
if vlan == nil {
log.Fatalf("Could not find the vlan %d", vlanId)
}
// Make sure the flood lists are empty
if (vlan.allFlood.NumOutput() != 0) || (vlan.localFlood.NumOutput() != 0) {
log.Fatalf("VLAN flood list is not empty")
}
// make sure there are no mac routes still installed in this vlan
for _, macRoute := range self.macRouteDb {
if macRoute.Vni == vni {
log.Fatalf("Vlan %d still has routes. Route: %+v", vlanId, macRoute)
}
}
// Uninstall the flood lists
vlan.allFlood.Delete()
vlan.localFlood.Delete()
// Remove it from DB
delete(self.vlanDb, vlanId)
return nil
}
开发者ID:shwethab,项目名称:netplugin,代码行数:28,代码来源:vxlanBridge.go
示例20: Show
func Show(cmd *cli.Cmd) {
applicationUuid := cmd.String(cli.StringArg{
Name: "APPLICATION_UUID",
Desc: "Application UUID",
HideValue: true,
})
uuid := cmd.String(cli.StringArg{
Name: "DEPLOYMENT_UUID",
Desc: "Deployment UUID",
HideValue: true,
})
cmd.Action = func() {
d := deployments.Deployment{}
deployment, resp, errs := d.Show(*applicationUuid, *uuid)
if len(errs) > 0 {
log.Fatalf("Could not retrieve deployment: %s", errs[0])
}
if resp.StatusCode != 200 {
log.Fatalf("Could not retrieve deployment: %s", resp.Status)
}
printDeploymentDetail(*deployment)
}
}
开发者ID:dubsquared,项目名称:kumoru-cli,代码行数:27,代码来源:deployments.go
注:本文中的github.com/Sirupsen/logrus.Fatalf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论