2014-05-05 07:37:44 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2014-05-09 10:49:22 +04:00
|
|
|
"github.com/siddontang/ledisdb/ledis"
|
2014-05-05 07:37:44 +04:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
2014-05-09 05:17:28 +04:00
|
|
|
"runtime"
|
2014-05-05 07:37:44 +04:00
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
2014-05-09 10:49:22 +04:00
|
|
|
var configFile = flag.String("config", "", "ledisdb config file")
|
2014-05-05 07:37:44 +04:00
|
|
|
|
|
|
|
func main() {
|
2014-05-09 05:17:28 +04:00
|
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
|
2014-05-05 07:37:44 +04:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if len(*configFile) == 0 {
|
|
|
|
panic("must use a config file")
|
|
|
|
}
|
|
|
|
|
2014-05-09 10:49:22 +04:00
|
|
|
cfg, err := ledis.NewConfigWithFile(*configFile)
|
2014-05-05 07:37:44 +04:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2014-05-09 10:49:22 +04:00
|
|
|
var app *ledis.App
|
|
|
|
app, err = ledis.NewApp(cfg)
|
2014-05-05 07:37:44 +04:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
sc := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(sc,
|
|
|
|
syscall.SIGHUP,
|
|
|
|
syscall.SIGINT,
|
|
|
|
syscall.SIGTERM,
|
|
|
|
syscall.SIGQUIT)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
<-sc
|
|
|
|
|
|
|
|
app.Close()
|
|
|
|
}()
|
|
|
|
|
|
|
|
app.Run()
|
|
|
|
}
|