本文整理汇总了Golang中github.com/qiniu/log.Fatal函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatal函数的具体用法?Golang Fatal怎么用?Golang Fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GenerateCRSBitMatrix
// int *cauchy_original_coding_matrix(int k, int m, int w);
// int *jerasure_matrix_to_bitmatrix(k, m, w, matrix);
func GenerateCRSBitMatrix(k, m, w int) []int {
gom := make([]int, 0)
matrix := C.cauchy_original_coding_matrix(C.int(k), C.int(m), C.int(w))
if matrix == nil {
log.Fatal("erasure: cannot make matrix")
}
bitmatrix := C.jerasure_matrix_to_bitmatrix(C.int(k), C.int(m), C.int(w), matrix)
if bitmatrix == nil {
log.Fatal("erasure: cannot make matrix")
}
length := int(k * m * w * w)
hdr := reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(bitmatrix)),
Len: length,
Cap: length,
}
matrixSlice := *(*[]C.int)(unsafe.Pointer(&hdr))
for _, e := range matrixSlice {
gom = append(gom, int(e))
}
return gom
}
示例2: InstallAction
func InstallAction(c *cli.Context) {
if c.Bool("debug") {
log.SetOutputLevel(log.Ldebug)
}
if len(c.Args()) < 1 {
log.Fatal("Need at lease one argument")
}
// log.Println(GOBIN)
pkgName := c.Args().First()
// TODO: use myname for now
if len(strings.Split(pkgName, "/")) == 1 {
pkgName = "gobuild-official/" + pkgName
}
prompt("Repository %v", pkgName)
dest, err := downloadSource(pkgName)
if err != nil {
log.Fatal(err)
}
err = deployPackage(pkgName, dest, GOBIN)
if err != nil {
log.Fatal(err)
}
prompt("Program [%s] installed", pkgName)
}
示例3: init
func init() {
cfg := new(config)
in, err := ioutil.ReadFile("config.yaml")
if err != nil {
log.Fatal(err)
}
err = goyaml.Unmarshal(in, cfg)
if err != nil {
log.Fatal(err)
}
flag.Parse()
log.SetOutputLevel(log.Ldebug)
if *environment == "development" {
opts = &cfg.Development
} else {
opts = &cfg.Production
}
fmt.Println("== environment:", *environment, "==")
utils.Dump(opts)
conf.ACCESS_KEY = opts.AccessKey
conf.SECRET_KEY = opts.SecretKey
// render html templates from templates directory
m.Use(render.Renderer(render.Options{
Layout: "layout",
}))
InitRouter()
}
示例4: main
func main() {
var err error
err = database.InitDB(opts.Driver, opts.DataSource)
if err != nil {
log.Fatal(err)
}
log.Info("gobuild service stated ...")
http.Handle("/", m)
http.Handle("/websocket/", websocket.Handler(WsBuildServer))
http.HandleFunc("/hello", HelloServer)
if *secure {
go func() {
er := http.ListenAndServeTLS(":443", "bin/ssl.crt", "bin/ssl.key", nil)
if er != nil {
log.Error(er)
}
}()
}
err = http.ListenAndServe(opts.ListenAddr, nil)
if err != nil {
log.Fatal(err)
}
}
示例5: wrap
func wrap(f interface{}) func(*cli.Context) {
return func(ctx *cli.Context) {
if ctx.GlobalBool("debug") {
log.SetOutputLevel(log.Ldebug)
}
sockPath := filepath.Join(GOSUV_HOME, "gosuv.sock")
if err := testConnection("unix", sockPath); err != nil {
log.Fatal(err)
}
conn, err := connect(ctx)
if err != nil {
log.Fatal(err)
}
defer conn.Close()
programClient := pb.NewProgramClient(conn)
gosuvClient := pb.NewGoSuvClient(conn)
inj := inject.New()
inj.Map(programClient)
inj.Map(gosuvClient)
inj.Map(ctx)
inj.Invoke(f)
}
}
示例6: runUpdate
func runUpdate(c *cli.Context) {
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
if cmd == "" {
return
}
setup(path.Join(setting.LogRootPath, "update.log"))
args := c.Args()
if len(args) != 3 {
qlog.Fatal("received less 3 parameters")
} else if args[0] == "" {
qlog.Fatal("refName is empty, shouldn't use")
}
//updateEnv(args[0], args[1], args[2])
userName := os.Getenv("userName")
userId, _ := strconv.ParseInt(os.Getenv("userId"), 10, 64)
//repoId := os.Getenv("repoId")
repoUserName := os.Getenv("repoUserName")
repoName := os.Getenv("repoName")
models.Update(args[0], args[1], args[2], userName, repoUserName, repoName, userId)
}
示例7: AddAction
func AddAction(ctx *cli.Context, client pb.GoSuvClient) {
name := ctx.String("name")
if name == "" {
name = filepath.Base(ctx.Args()[0])
}
dir, _ := os.Getwd()
if len(ctx.Args()) < 1 {
log.Fatal("need at least one args")
}
cmdName := ctx.Args().First()
cmdPath, err := exec.LookPath(cmdName)
if err != nil {
log.Fatal(err)
}
req := new(pb.ProgramInfo)
req.Name = ctx.String("name")
req.Directory = dir
req.Command = append([]string{cmdPath}, ctx.Args().Tail()...)
req.Environ = ctx.StringSlice("env")
res, err := client.Create(context.Background(), req)
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Message)
}
示例8: actionShutdown
func actionShutdown(c *cli.Context) error {
restart := c.Bool("restart")
if restart {
log.Fatal("Restart not implemented.")
}
ret, err := postForm("/api/shutdown", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(ret.Value)
return nil
}
示例9: main
func main() {
kingpin.Version(VERSION)
kingpin.CommandLine.VersionFlag.Short('v')
kingpin.CommandLine.HelpFlag.Short('h')
kingpin.Parse()
if !cfg.Server.Enable && localAddr == "" {
kingpin.Usage()
return
}
if !cfg.Debug {
log.SetOutputLevel(log.Linfo)
} else {
log.SetOutputLevel(log.Ldebug)
}
pURL, err := parseURL(localAddr, cfg.Proto)
if err != nil {
log.Fatal(err)
}
if cfg.Server.Enable {
_, port, _ := net.SplitHostPort(pURL.Host)
if port == "" {
port = "80"
}
addr := net.JoinHostPort("0.0.0.0", port)
if cfg.Server.Domain == "" {
cfg.Server.Domain = "localhost" //cfg.Server.Addr
}
fmt.Printf("proxylocal: server listen on %v, domain is %v\n", addr, cfg.Server.Domain)
ps := pxlocal.NewProxyServer(cfg.Server.Domain)
log.Fatal(http.ListenAndServe(addr, ps))
}
// var localAddr = flag.Arg(0)
// if !regexp.MustCompile("^(http|https|tcp)://").MatchString(localAddr) {
// if _, err := strconv.Atoi(localAddr); err == nil { // only contain port
// localAddr = "localhost:" + localAddr
// } else {
// //localAddr += ":80"
// }
// localAddr = cfg.Proto + "://" + localAddr
// }
// pURL, err := url.Parse(localAddr)
fmt.Println("proxy URL:", pURL)
pxlocal.StartAgent(pURL, cfg.SubDomain, cfg.Server.Addr, cfg.ProxyPort, cfg.Data)
}
示例10: StartAgent
func StartAgent(pURL *url.URL, subdomain, serverAddr string, remoteListenPort int, data string) {
log.Debug("start proxy", pURL)
if !regexp.MustCompile("^http[s]://").MatchString(serverAddr) {
serverAddr = "http://" + serverAddr
}
sURL, err := url.Parse(serverAddr)
if err != nil {
log.Fatal(err)
}
sURL.Path = "/ws"
log.Debug("server host:", sURL.Host)
conn, err := net.Dial("tcp", sURL.Host)
if err != nil {
log.Fatal(err)
}
// specify remote listen port
sURL.Scheme = "ws"
query := sURL.Query()
query.Add("protocol", pURL.Scheme)
query.Add("subdomain", subdomain)
query.Add("data", data)
if remoteListenPort != 0 {
query.Add("port", strconv.Itoa(remoteListenPort))
}
sURL.RawQuery = query.Encode()
log.Debug(sURL)
wsclient, _, err := websocket.NewClient(conn, sURL, nil, 1024, 1024)
if err != nil {
log.Fatal(err)
}
defer wsclient.Close()
go idleWsSend(wsclient)
for {
var msg Msg
if err := wsclient.ReadJSON(&msg); err != nil {
fmt.Println("client exit: " + err.Error())
break
}
log.Debug("recv:", msg)
// sURL: serverURL
rnl := NewRevNetListener()
go handleRevConn(pURL, rnl)
handleWsMsg(msg, sURL, rnl)
}
}
示例11: readConfig
func readConfig() {
flag.Parse()
if !FileExists(*cfgFile) {
log.Fatal("Need config file")
}
parseCfgFile(*cfgFile, m)
}
示例12: RoundTrip
func (r transportImpl) RoundTrip(req *http.Request) (resp *http.Response, err error) {
h := Route[req.Host]
if h == nil {
log.Fatal("Server not found:", req.Host)
}
cp := *req
cp.Body = &mockServerRequestBody{req.Body, false}
req = &cp
rw := httptest.NewRecorder()
h.ServeHTTP(rw, req)
ctlen := int64(-1)
if v := rw.HeaderMap.Get("Content-Length"); v != "" {
ctlen, _ = strconv.ParseInt(v, 10, 64)
}
return &http.Response{
Status: "",
StatusCode: rw.Code,
Header: rw.HeaderMap,
Body: ioutil.NopCloser(rw.Body),
ContentLength: ctlen,
TransferEncoding: nil,
Close: false,
Trailer: nil,
Request: req,
}, nil
}
示例13: actionConfigTest
func actionConfigTest(c *cli.Context) error {
if _, _, err := newSupervisorHandler(); err != nil {
log.Fatal(err)
}
log.Println("test is successful")
return nil
}
示例14: ServeAddr
func ServeAddr(addr string) error {
InitServer()
t := tango.New()
t.Group("/api", func(g *tango.Group) {
g.Get("/version", versionHandler)
g.Post("/shutdown", shutdownHandler)
g.Post("/programs", addHandler)
g.Get("/programs", statusHandler)
})
go t.Run(addr)
lis, err := net.Listen("unix", filepath.Join(GOSUV_HOME, "gosuv.sock"))
if err != nil {
log.Fatal(err)
}
handleSignal(lis)
pbServ := &PbSuvServer{}
pbProgram := &PbProgram{}
grpcServ := grpc.NewServer()
pb.RegisterGoSuvServer(grpcServ, pbServ)
pb.RegisterProgramServer(grpcServ, pbProgram)
pbServ.lis = lis
grpcServ.Serve(lis)
return fmt.Errorf("Address: %s has been used", addr)
}
示例15: init
func init() {
var err error
logfd, err = os.OpenFile("build.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
log.Fatal("create build.log file failed:", err)
}
}