2014-05-05 07:37:44 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"github.com/siddontang/go-ssdb/ssdb"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
2014-05-09 05:17:28 +04:00
|
|
|
"runtime"
|
2014-05-05 07:37:44 +04:00
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
var configFile = flag.String("config", "", "ssdb config file")
|
|
|
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg, err := ssdb.NewConfigWithFile(*configFile)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
var app *ssdb.App
|
|
|
|
app, err = ssdb.NewApp(cfg)
|
|
|
|
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()
|
|
|
|
}
|