本文整理汇总了Golang中github.com/astaxie/beego/logs.BeeLogger.Alert方法的典型用法代码示例。如果您正苦于以下问题:Golang BeeLogger.Alert方法的具体用法?Golang BeeLogger.Alert怎么用?Golang BeeLogger.Alert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/astaxie/beego/logs.BeeLogger
的用法示例。
在下文中一共展示了BeeLogger.Alert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StartLocalServer
func StartLocalServer(ctx *macaron.Context, log *logs.BeeLogger) (int, []byte) {
var stdout, stderr bytes.Buffer
header := ctx.Req.Header
ip := header.Get("ip")
port := header.Get("port")
masterip := header.Get("masterip")
masterport := header.Get("masterport")
chunknum := header.Get("chunknum")
groupid := header.Get("groupid")
datadir := header.Get("datadir")
errlogdir := header.Get("errlogdir")
masterlistenmode := header.Get("masterlistenmode")
// check if chunkserver binary exsist,if not ,create it
_, err := os.Stat("./oss/chunkserver/spy_server")
if err != nil && os.IsNotExist(err) {
return http.StatusInternalServerError, []byte("Cannot find chunkserver excution file")
}
// check if errlog folder exsist , if not ,create it
_, err = os.Stat(errlogdir)
if err != nil || os.IsNotExist(err) {
os.MkdirAll(errlogdir, 0777)
}
// check if data folder exsist , if not ,create it
_, err = os.Stat(datadir)
if err != nil || os.IsNotExist(err) {
os.MkdirAll(datadir, 0777)
}
// execute chunkserver start script in a new goroutine, if failed, send https request to notify master node
go func() {
cmd := exec.Command("./oss/chunkserver/install.sh", "-i", ip, "-p", port, "-m", masterip, "-n", masterport, "-c", chunknum, "-g", groupid, "-d", datadir, "-e", errlogdir)
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err = cmd.Run()
if err != nil {
log.Alert("[OSS]Start local ChunkServer error, error INFO: %v", err)
log.Alert("[OSS]Start local ChunkServer error, STDOUT: %s", stdout.Bytes())
log.Alert("[OSS]Start local ChunkServer error, STDERR: %s", stderr.Bytes())
header2send := make(map[string][]string, 0)
header2send["nodeip"] = []string{ip}
header2send["nodeport"] = []string{port}
header2send["groupid"] = []string{groupid}
header2send["stderr"] = []string{string(stderr.Bytes())}
header2send["stdout"] = []string{string(stdout.Bytes())}
switch masterlistenmode {
case "http":
result, statusCode, err := util.Call("PUT", "http://"+masterip+":80", "/oss/chunkserver/info", nil, header2send)
if err != nil {
log.Error("[OSS] Sent chunkserver info back to chunkmaster error: %v", err)
}
if statusCode != http.StatusOK {
log.Error("[OSS] Sent chunkserver info back to chunkmaster failed STATUS CODE:%v ,result:%s", statusCode, result)
}
default:
result, statusCode, err := util.CallHttps("PUT", "https://"+masterip+":443", "/oss/chunkserver/info", nil, header2send)
if err != nil {
log.Error("[OSS] Sent chunkserver info back to chunkmaster error: %v", err)
}
if statusCode != http.StatusOK {
log.Error("[OSS] Sent chunkserver info back to chunkmaster failed STATUS CODE:%v ,result:%s", statusCode, result)
}
}
}
}()
return http.StatusOK, []byte("")
}