|
@@ -0,0 +1,45 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "github.com/tsdrm/go-tool/config"
|
|
|
+ "github.com/tsdrm/go-tool/log"
|
|
|
+ "userline"
|
|
|
+)
|
|
|
+
|
|
|
+func main() {
|
|
|
+ var conf = "config.conf"
|
|
|
+ var cfg = config.NewConfig()
|
|
|
+ var err = cfg.Config(conf)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("Main read config: %v error: %v", conf, err)
|
|
|
+ log.E("Main read config: %v error: %v", conf, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ cfg.Print()
|
|
|
+
|
|
|
+ err = log.RedirectFile(cfg.String("LOG_PATH"))
|
|
|
+ if err != nil {
|
|
|
+ log.W("Main redirect log to file: %v error: %v", cfg.String("LOG_PATH"), err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ userline.HOST_ADDR = cfg.String("HOST_ADDR")
|
|
|
+
|
|
|
+ // dial to mongodb
|
|
|
+ err = userline.Dial(cfg.String("DB_CONN"), cfg.String("DB_NAME"))
|
|
|
+ if err != nil {
|
|
|
+ log.E("Main dial mongodb with DB_CONN: %v, DB_NAME: %v error: %v", cfg.String("DB_CONN"), cfg.String("DB_NAME"), err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ log.D("Main dial mongodb with DB_CONN: %v, DB_NAME: %v success", cfg.String("DB_CONN"), cfg.String("DB_NAME"))
|
|
|
+
|
|
|
+ // register http handler
|
|
|
+
|
|
|
+ log.D("Main server will start !!!")
|
|
|
+
|
|
|
+ // start
|
|
|
+ userline.GetNum()
|
|
|
+
|
|
|
+ log.D("Main server will stop !!!")
|
|
|
+}
|