func (c *Container) create() (err error) { c.Size = c.s.Conf.ContainerSize if err = c.falloc(); err != nil { aelog.Infoln("Fallocate doesn't work:", err, "\nTry to truncate...") if err = c.fallocTruncate(); err != nil { return } } return }
func main() { defer func() { /* if r := recover(); r != nil { fmt.Println("Error!") fmt.Println(r) } */ }() if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { panic(err) } pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } if *httpprofile { go func() { log.Println(ghttp.ListenAndServe(":6060", nil)) }() } var err error if *isPrintVersion { printVersion() return } if *isPrintHelp { printHelp() return } // If configFile not specified - show help if *configFile == "" { printHelp() return } // Init config c := &config.Config{} c.ReadFile(*configFile) // Init logger aelog.DefaultLogger, err = aelog.New(c.LogFile, c.LogLevel) if err != nil { panic(err) } // Init storage stor := &storage.Storage{} stor.Init(c) err = stor.Open() if err != nil { panic(err) } defer stor.Close() // init access log is needed var al *aelog.AntLog if c.LogAccess != "" { al, err = aelog.New(c.LogAccess, aelog.LOG_PRINT) if err != nil { panic(err) } } // Run server http.RunServer(stor, al) // Run rpc server rpcserver.StartRpcServer(stor) aelog.Infof("Run working (use %d cpus)", c.CpuNum) interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, syscall.SIGKILL, os.Interrupt, syscall.SIGTERM) sig := <-interrupt aelog.Infof("Catched signal %v. Stop server", sig) stor.Dump() aelog.Infoln("") }