本文整理汇总了Golang中github.com/Sirupsen/logrus.Fatalf函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalf函数的具体用法?Golang Fatalf怎么用?Golang Fatalf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatalf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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)
}
}
}
示例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)
}
}
示例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
}
示例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")
}
示例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)
}
}
示例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
}
示例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)
}
}
示例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
}
示例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)
}
示例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)
}
}
示例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)
}
}
示例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
}
示例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)
}
示例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))
}