本文整理汇总了Golang中github.com/qiniu/log.Fatal函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatal函数的具体用法?Golang Fatal怎么用?Golang Fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:missmayo,项目名称:cfs,代码行数:27,代码来源:erasure.go
示例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)
}
开发者ID:carriercomm,项目名称:gopack,代码行数:27,代码来源:install.go
示例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()
}
开发者ID:matm,项目名称:gobuild,代码行数:32,代码来源:main.go
示例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)
}
}
开发者ID:matm,项目名称:gobuild,代码行数:25,代码来源:main.go
示例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)
}
}
开发者ID:mehulsbhatt,项目名称:gosuv,代码行数:26,代码来源:gosuv.go
示例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)
}
开发者ID:hilerchyn,项目名称:gogs,代码行数:25,代码来源:update.go
示例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)
}
开发者ID:mehulsbhatt,项目名称:gosuv,代码行数:29,代码来源:gosuv.go
示例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
}
开发者ID:codeskyblue,项目名称:gosuv,代码行数:12,代码来源:gosuv.go
示例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)
}
开发者ID:Andy-hpliu,项目名称:proxylocal,代码行数:49,代码来源:main.go
示例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)
}
}
开发者ID:Andy-hpliu,项目名称:proxylocal,代码行数:49,代码来源:client.go
示例11: readConfig
func readConfig() {
flag.Parse()
if !FileExists(*cfgFile) {
log.Fatal("Need config file")
}
parseCfgFile(*cfgFile, m)
}
开发者ID:codeskyblue,项目名称:shweb,代码行数:7,代码来源:main.go
示例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
}
开发者ID:qiniu,项目名称:mockhttp.v1,代码行数:31,代码来源:mockhttp.go
示例13: actionConfigTest
func actionConfigTest(c *cli.Context) error {
if _, _, err := newSupervisorHandler(); err != nil {
log.Fatal(err)
}
log.Println("test is successful")
return nil
}
开发者ID:codeskyblue,项目名称:gosuv,代码行数:7,代码来源:gosuv.go
示例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)
}
开发者ID:insionng,项目名称:gosuv,代码行数:30,代码来源:web.go
示例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)
}
}
开发者ID:matm,项目名称:gobuild,代码行数:7,代码来源:build.go
示例16: actionReload
func actionReload(c *cli.Context) error {
ret, err := postForm("/api/reload", nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(ret.Value)
return nil
}
开发者ID:codeskyblue,项目名称:gosuv,代码行数:8,代码来源:gosuv.go
示例17: VersionAction
func VersionAction(ctx *cli.Context, client pb.GoSuvClient) {
fmt.Printf("Client: %s\n", GOSUV_VERSION)
res, err := client.Version(context.Background(), &pb.NopRequest{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Server: %s\n", res.Message)
}
开发者ID:mehulsbhatt,项目名称:gosuv,代码行数:8,代码来源:gosuv.go
示例18: actionStartServer
func actionStartServer(c *cli.Context) error {
suv, hdlr, err := newSupervisorHandler()
if err != nil {
log.Fatal(err)
}
auth := cfg.Server.HttpAuth
if auth.Enabled {
hdlr = httpauth.SimpleBasicAuth(auth.User, auth.Password)(hdlr)
}
http.Handle("/", hdlr)
addr := cfg.Server.Addr
if c.Bool("foreground") {
suv.AutoStartPrograms()
log.Printf("server listen on %v", addr)
log.Fatal(http.ListenAndServe(addr, nil))
} else {
if checkServerStatus() == nil {
fmt.Println("server is already running")
return nil
}
logPath := filepath.Join(defaultConfigDir, "gosuv.log")
logFd, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
if err != nil {
log.Fatalf("create file %s failed: %v", logPath, err)
}
cmd := exec.Command(os.Args[0], "start-server", "-f")
cmd.Stdout = logFd
cmd.Stderr = logFd
err = cmd.Start()
if err != nil {
log.Fatal(err)
}
select {
case err = <-GoFunc(cmd.Wait):
log.Fatalf("server started failed, %v", err)
case <-time.After(200 * time.Millisecond):
showAddr := addr
if strings.HasPrefix(addr, ":") {
showAddr = "0.0.0.0" + addr
}
fmt.Printf("server started, listening on %s\n", showAddr)
}
}
return nil
}
开发者ID:codeskyblue,项目名称:gosuv,代码行数:46,代码来源:gosuv.go
示例19: StatusAction
func StatusAction(client pb.GoSuvClient) {
res, err := client.Status(context.Background(), &pb.NopRequest{})
if err != nil {
log.Fatal(err)
}
for _, ps := range res.GetPrograms() {
fmt.Printf("%-10s\t%-8s\t%s\n", ps.Name, ps.Status, ps.Extra)
}
}
开发者ID:mehulsbhatt,项目名称:gosuv,代码行数:9,代码来源:gosuv.go
示例20: actionStatus
func actionStatus(c *cli.Context) error {
err := checkServerStatus()
if err != nil {
log.Fatal(err)
} else {
log.Println("Server is running, OK.")
}
return nil
}
开发者ID:codeskyblue,项目名称:gosuv,代码行数:9,代码来源:gosuv.go
注:本文中的github.com/qiniu/log.Fatal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论