本文整理汇总了Golang中minilog.Fatalln函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatalln函数的具体用法?Golang Fatalln怎么用?Golang Fatalln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatalln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: httpTLSServer
func httpTLSServer(p string) {
log.Debugln("httpTLSServer")
httpSetup()
hitTLSChan = make(chan uint64, 1024)
go hitTLSCounter()
cert, key := generateCerts()
//log.Fatalln(http.ListenAndServeTLS(":https", cert, key, nil))
server := &http.Server{
Addr: ":https",
Handler: nil,
}
config := &tls.Config{}
if config.NextProtos == nil {
config.NextProtos = []string{"http/1.1"}
}
var err error
config.Certificates = make([]tls.Certificate, 1)
config.Certificates[0], err = tls.LoadX509KeyPair(cert, key)
if err != nil {
log.Fatalln(err)
}
conn, err := net.Listen(p, ":https")
if err != nil {
log.Fatalln(err)
}
tlsListener := tls.NewListener(conn, config)
log.Fatalln(server.Serve(tlsListener))
}
示例2: smtpServer
func smtpServer(p string) {
log.Debugln("smtpServer")
certfile, keyfile := generateCerts()
cert, err := tls.LoadX509KeyPair(certfile, keyfile)
if err != nil {
log.Fatalln("couldn't get cert: ", err)
}
TLSconfig = &tls.Config{Certificates: []tls.Certificate{cert}, ClientAuth: tls.VerifyClientCertIfGiven, ServerName: myFQDN}
listener, err := net.Listen(p, "0.0.0.0"+smtpPort)
if err != nil {
log.Fatalln(err)
}
for {
conn, err := listener.Accept()
if err != nil {
log.Debugln(err)
continue
}
client := NewSMTPClientSession(conn)
go client.Handler()
smtpReportChan <- 1
}
}
示例3: main
func main() {
flag.Parse()
logSetup()
log.Debug("using minimega: %v", *f_minimega)
// invoke minimega and get the doc json
doc, err := exec.Command(*f_minimega, "-cli").Output()
if err != nil {
log.Fatalln(err)
}
log.Debug("got doc: %v", string(doc))
// decode the JSON for our template
if err := json.Unmarshal(doc, &handlers); err != nil {
log.Fatalln(err)
}
exclude = strings.Split(*f_exclude, ",")
values = strings.Split(*f_values, ",")
for {
if err := fuzz(); err != nil {
log.Fatal("fuzz: %v", err)
}
if err := cleanup(); err != nil {
log.Fatal("cleanup: %v", err)
}
}
}
示例4: handler
// client connection handler and transport. Messages on chan out are sent to
// the ron server. Incoming messages are put on the message queue to be routed
// by the mux. The entry to handler() also creates the tunnel transport.
func (c *Client) handler() {
log.Debug("ron handler")
enc := gob.NewEncoder(c.conn)
dec := gob.NewDecoder(c.conn)
tunnelQuit := make(chan bool)
defer func() { tunnelQuit <- true }()
// create a tunnel
go c.handleTunnel(false, tunnelQuit)
// handle client i/o
go func() {
for {
m := <-c.out
err := enc.Encode(m)
if err != nil {
log.Fatalln(err)
}
}
}()
for {
var m Message
err := dec.Decode(&m)
if err != nil {
log.Fatalln(err)
}
c.in <- &m
}
}
示例5: main
func main() {
flag.Parse()
logSetup()
log.Debug("using minimega: %v", *f_minimega)
log.Debug("using doc template: %v", *f_template)
// invoke minimega and get the doc json
doc, err := exec.Command(*f_minimega, "-cli").Output()
if err != nil {
log.Fatalln(err)
}
log.Debug("got doc: %v", string(doc))
// decode the JSON for our template
var handlers []*minicli.Handler
err = json.Unmarshal(doc, &handlers)
if err != nil {
log.Fatalln(err)
}
// populate the apigen date for the template
year, month, day := time.Now().Date()
api := apigen{
Date: fmt.Sprintf("%v %v %v", day, month, year),
}
// populate the major sections for the template
for _, v := range handlers {
var p string
if strings.HasPrefix(v.SharedPrefix, "clear") {
p = strings.TrimPrefix(v.SharedPrefix, "clear ")
} else {
p = v.SharedPrefix
}
if strings.HasPrefix(p, ".") {
api.Builtins = append(api.Builtins, v)
} else if strings.HasPrefix(p, "mesh") {
api.Mesh = append(api.Mesh, v)
} else if strings.HasPrefix(p, "vm") {
api.VM = append(api.VM, v)
} else {
api.Host = append(api.Host, v)
}
}
// run the template and print to stdout
var out bytes.Buffer
t, err := template.ParseFiles(*f_template)
if err != nil {
log.Fatalln(err)
}
err = t.Execute(&out, api)
if err != nil {
log.Fatalln(err)
}
fmt.Println(out.String())
}
示例6: main
func main() {
// flags
flag.Parse()
logSetup()
if *f_u != "" {
log.Debug("updating with file: %v", *f_u)
err := update(filepath.Join(*f_path, "minirouter"), *f_u)
if err != nil {
log.Errorln(err)
}
return
}
// check for a running instance of minirouter
_, err := os.Stat(filepath.Join(*f_path, "minirouter"))
if err == nil {
if !*f_force {
log.Fatalln("minirouter appears to already be running, override with -force")
}
log.Warn("minirouter may already be running, proceed with caution")
err = os.Remove(filepath.Join(*f_path, "minirouter"))
if err != nil {
log.Fatalln(err)
}
}
log.Debug("using path: %v", *f_path)
// attempt to set up the base path
err = os.MkdirAll(*f_path, os.FileMode(0770))
if err != nil {
log.Fatal("mkdir base path: %v", err)
}
// start the domain socket service
go commandSocketStart()
// signal handling
sig := make(chan os.Signal, 1024)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
<-sig
// cleanup
err = os.Remove(filepath.Join(*f_path, "minirouter"))
if err != nil {
log.Fatalln(err)
}
}
示例7: cliVmConfigField
func cliVmConfigField(c *minicli.Command, field string) *minicli.Response {
resp := &minicli.Response{Host: hostname}
// If there are no args it means that we want to display the current value
nArgs := len(c.StringArgs) + len(c.ListArgs) + len(c.BoolArgs)
var ok bool
var fns VMConfigFns
var config interface{}
// Find the right config functions, baseConfigFns has highest priority
if fns, ok = baseConfigFns[field]; ok {
config = &vmConfig.BaseConfig
} else if fns, ok = kvmConfigFns[field]; ok {
config = &vmConfig.KVMConfig
} else {
log.Fatalln("unknown config field: `%s`", field)
}
if nArgs == 0 {
resp.Response = fns.Print(config)
} else {
if err := fns.Update(config, c); err != nil {
resp.Error = err.Error()
}
}
return resp
}
示例8: cliClearVmConfig
func cliClearVmConfig(c *minicli.Command) *minicli.Response {
resp := &minicli.Response{Host: hostname}
var clearAll = len(c.BoolArgs) == 0
var clearKVM = clearAll || (len(c.BoolArgs) == 1 && c.BoolArgs["kvm"])
var cleared bool
for k, fns := range baseConfigFns {
if clearAll || c.BoolArgs[k] {
fns.Clear(&vmConfig.BaseConfig)
cleared = true
}
}
for k, fns := range kvmConfigFns {
if clearKVM || c.BoolArgs[k] {
fns.Clear(&vmConfig.KVMConfig)
cleared = true
}
}
if !cleared {
log.Fatalln("no callback defined for clear")
}
return resp
}
示例9: teardown
func teardown() {
// Clear namespace so that we hit all the VMs
SetNamespace("")
vncClear()
clearAllCaptures()
vms.Kill(Wildcard)
dnsmasqKillAll()
ksmDisable()
vms.Flush()
vms.CleanDirs()
containerTeardown()
if err := bridgesDestroy(); err != nil {
log.Errorln(err)
}
commandSocketRemove()
goreadline.Rlcleanup()
if err := os.Remove(filepath.Join(*f_base, "minimega.pid")); err != nil {
log.Fatalln(err)
}
if cpuProfileOut != nil {
pprof.StopCPUProfile()
cpuProfileOut.Close()
}
os.Exit(0)
}
示例10: heartbeat
// client heartbeat sent periodically be periodic(). heartbeat() sends the
// client info and any queued responses.
func (c *Client) heartbeat() {
log.Debugln("heartbeat")
hostname, err := os.Hostname()
if err != nil {
log.Fatalln(err)
}
cin := &Client{
UUID: c.UUID,
Arch: runtime.GOARCH,
OS: runtime.GOOS,
Hostname: hostname,
}
macs, ips := getNetworkInfo()
cin.MAC = macs
cin.IP = ips
c.responseLock.Lock()
cin.Responses = c.Responses
c.Responses = []*Response{}
c.responseLock.Unlock()
m := &Message{
Type: MESSAGE_CLIENT,
UUID: c.UUID,
Client: cin,
}
log.Debug("heartbeat %v", cin)
c.out <- m
c.lastHeartbeat = time.Now()
}
示例11: httpServer
func httpServer(p string) {
log.Debugln("httpServer")
httpSetup()
hitChan = make(chan uint64, 1024)
go hitCounter()
server := &http.Server{
Addr: ":http",
Handler: nil,
}
conn, err := net.Listen(p, ":http")
if err != nil {
log.Fatalln(err)
}
log.Fatalln(server.Serve(conn))
}
示例12: process
func process(p string) string {
path, err := exec.LookPath(externalProcesses[p])
if err != nil {
log.Fatalln(err)
return ""
}
return path
}
示例13: sshServer
func sshServer(p string) {
log.Debugln("sshServer")
config := &ssh.ServerConfig{
PasswordCallback: func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error) {
if conn.User() == "protonuke" && string(password) == "password" {
return &ssh.Permissions{}, nil
}
return nil, errors.New("invalid user/password")
},
}
private, err := ssh.ParsePrivateKey([]byte(id_rsa))
if err != nil {
log.Fatalln(err)
}
config.AddHostKey(private)
// Once a ServerConfig has been configured, connections can be accepted.
listener, err := net.Listen(p, PORT)
if err != nil {
log.Fatalln(err)
}
for {
conn, err := listener.Accept()
if err != nil {
log.Errorln(err)
continue
}
// Before use, a handshake must be performed on the incoming net.Conn.
_, chans, reqs, err := ssh.NewServerConn(conn, config)
if err != nil {
log.Errorln(err)
continue
}
// The incoming Request channel must be serviced.
go ssh.DiscardRequests(reqs)
go sshHandleChannels(conn, chans)
}
}
示例14: registerTID
// register a transaction ID, adding a return channel to the mux
func (t *Tunnel) registerTID(TID int32) chan *tunnelMessage {
if _, ok := t.tids[TID]; ok {
log.Fatalln(fmt.Sprintf("tid %v already exists!", TID))
}
c := make(chan *tunnelMessage, 1024)
t.tids[TID] = c
return c
}
示例15: ccStart
func ccStart() {
var err error
ccNode, err = ron.NewServer(*f_ccPort, *f_iomBase)
if err != nil {
log.Fatalln(fmt.Errorf("creating cc node %v", err))
}
log.Debug("created ron node at %v %v", ccPort, *f_base)
}