Merge branch 'develop'

This commit is contained in:
siddontang 2014-09-18 21:59:24 +08:00
commit 0aa1f95752
11 changed files with 21 additions and 15 deletions

View File

@ -23,7 +23,7 @@ func main() {
var err error
var f *os.File
if f, err = os.OpenFile(*dumpFile, os.O_CREATE|os.O_WRONLY, os.ModePerm); err != nil {
if f, err = os.OpenFile(*dumpFile, os.O_CREATE|os.O_WRONLY, 0644); err != nil {
println(err.Error())
return
}

View File

@ -2,6 +2,7 @@ package main
import (
"flag"
"fmt"
"github.com/siddontang/ledisdb/config"
"github.com/siddontang/ledisdb/server"
"log"
@ -15,6 +16,8 @@ import (
var configFile = flag.String("config", "", "ledisdb config file")
var dbName = flag.String("db_name", "", "select a db to use, it will overwrite the config's db name")
var usePprof = flag.Bool("pprof", false, "enable pprof")
var pprofPort = flag.Int("pprof_port", 6060, "pprof http port")
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
@ -60,9 +63,11 @@ func main() {
app.Close()
}()
if *usePprof {
go func() {
log.Println(http.ListenAndServe("localhost:6060", nil))
log.Println(http.ListenAndServe(fmt.Sprintf(":%d", *pprofPort), nil))
}()
}
app.Run()
}

View File

@ -117,7 +117,7 @@ func NewBinLog(cfg *config.Config) (*BinLog, error) {
l.path = path.Join(cfg.DataDir, "binlog")
if err := os.MkdirAll(l.path, os.ModePerm); err != nil {
if err := os.MkdirAll(l.path, 0755); err != nil {
return nil, err
}
@ -136,7 +136,7 @@ func (l *BinLog) flushIndex() error {
data := strings.Join(l.logNames, "\n")
bakName := fmt.Sprintf("%s.bak", l.indexName)
f, err := os.OpenFile(bakName, os.O_WRONLY|os.O_CREATE, 0666)
f, err := os.OpenFile(bakName, os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
log.Error("create binlog bak index error %s", err.Error())
return err
@ -217,7 +217,7 @@ func (l *BinLog) openNewLogFile() error {
lastName := l.getLogFile()
logPath := path.Join(l.path, lastName)
if l.logFile, err = os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY, 0666); err != nil {
if l.logFile, err = os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY, 0644); err != nil {
log.Error("open new logfile error %s", err.Error())
return err
}

View File

@ -42,6 +42,7 @@ func Open(cfg *config.Config) (*Ledis, error) {
l.ldb = ldb
if cfg.BinLog.MaxFileNum > 0 && cfg.BinLog.MaxFileSize > 0 {
println("binlog will be refactored later, use your own risk!!!")
l.binlog, err = NewBinLog(cfg)
if err != nil {
return nil, err

View File

@ -38,7 +38,7 @@ func (m *MasterInfo) Save(filePath string) error {
filePathBak := fmt.Sprintf("%s.bak", filePath)
var fd *os.File
fd, err = os.OpenFile(filePathBak, os.O_CREATE|os.O_WRONLY, os.ModePerm)
fd, err = os.OpenFile(filePathBak, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}
@ -250,7 +250,7 @@ func (m *master) fullSync() error {
}
dumpPath := path.Join(m.app.cfg.DataDir, "master.dump")
f, err := os.OpenFile(dumpPath, os.O_CREATE|os.O_WRONLY, os.ModePerm)
f, err := os.OpenFile(dumpPath, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
return err
}

View File

@ -18,7 +18,7 @@ func (s Store) String() string {
}
func (s Store) Open(dbPath string, cfg *config.Config) (driver.IDB, error) {
os.MkdirAll(dbPath, os.ModePerm)
os.MkdirAll(dbPath, 0755)
name := path.Join(dbPath, "ledis_bolt.db")
db := new(DB)
var err error

View File

@ -47,7 +47,7 @@ type DB struct {
}
func (s Store) Open(path string, cfg *config.Config) (driver.IDB, error) {
if err := os.MkdirAll(path, os.ModePerm); err != nil {
if err := os.MkdirAll(path, 0755); err != nil {
return nil, err
}

View File

@ -28,7 +28,7 @@ func (s Store) String() string {
}
func (s Store) Open(path string, cfg *config.Config) (driver.IDB, error) {
if err := os.MkdirAll(path, os.ModePerm); err != nil {
if err := os.MkdirAll(path, 0755); err != nil {
return nil, err
}

View File

@ -28,7 +28,7 @@ func (s Store) String() string {
}
func (s Store) Open(path string, cfg *config.Config) (driver.IDB, error) {
if err := os.MkdirAll(path, os.ModePerm); err != nil {
if err := os.MkdirAll(path, 0755); err != nil {
return nil, err
}

View File

@ -29,7 +29,7 @@ func (s Store) String() string {
}
func (s Store) Open(path string, cfg *config.Config) (driver.IDB, error) {
if err := os.MkdirAll(path, os.ModePerm); err != nil {
if err := os.MkdirAll(path, 0755); err != nil {
return nil, err
}

View File

@ -27,7 +27,7 @@ func Open(cfg *config.Config) (*DB, error) {
path := getStorePath(cfg)
if err := os.MkdirAll(path, os.ModePerm); err != nil {
if err := os.MkdirAll(path, 0755); err != nil {
return nil, err
}