Ejemplo n.º 1
0
// 自定义参数运行
func FlagRun() {
	var conf string
	var debug bool
	var trace bool
	var service string
	var serviceArr []string = []string{"mail", "order"}
	var ch chan bool = make(chan bool)
	flag.StringVar(&conf, "conf", "app.conf", "")
	flag.BoolVar(&debug, "debug", true, "")
	flag.BoolVar(&trace, "trace", true, "")
	flag.StringVar(&service, "service", strings.Join(serviceArr, ","), "")

	flag.Parse()

	appCtx = getAppCtx(conf)
	appCtx.Init(debug, trace)
	gof.CurrentApp = appCtx

	dps.Init(appCtx)

	if service != "all" {
		serviceArr = strings.Split(service, ",")
	}

	RegisterByName(serviceArr)
	Start()

	<-ch
}
Ejemplo n.º 2
0
func main() {
	var (
		port int
		ch   chan bool = make(chan bool)
		conf string
	)

	flag.IntVar(&port, "port", 1005, "")
	flag.StringVar(&conf, "conf", "app.conf", "")
	flag.Parse()

	gof.CurrentApp = core.NewMainApp(conf)
	dps.Init(gof.CurrentApp)
	cache.Initialize(gof.CurrentApp.Storage())
	tcpserve.DebugOn = true
	go tcpserve.ListenTcp(fmt.Sprintf(":%d", port))
	go func(mainCh chan bool) {
		ch := make(chan os.Signal)
		signal.Notify(ch, syscall.SIGTERM, syscall.SIGKILL)
		for {
			switch <-ch {
			case syscall.SIGKILL, syscall.SIGTERM:
				log.Println("[ Tcp][ Term] - tcp serve has term!")
				close(mainCh)
			}
		}
	}(ch)

	log.Println("[ TCP][ SERVE] - socket is served ... ")

	<-ch
}
Ejemplo n.º 3
0
// 自定义参数运行
func FlagRun() {
	var conf string
	var debug bool
	var trace bool
	var service string
	var serviceArr []string
	flag.StringVar(&conf, "conf", "app.conf", "")
	flag.BoolVar(&debug, "debug", true, "")
	flag.BoolVar(&trace, "trace", true, "")
	flag.StringVar(&service, "service", strings.Join(allService, ","), "")

	flag.Parse()

	appCtx = getAppCtx(conf)
	appCtx.Init(debug, trace)
	gof.CurrentApp = appCtx

	dps.Init(appCtx)

	if service == "all" {
		serviceArr = allService
	} else {
		serviceArr = strings.Split(service, ",")
	}

	bootService(serviceArr, true)
}
Ejemplo n.º 4
0
Archivo: init.go Proyecto: sunxboy/go2o
func Init(app gof.App) {
	dps.Init(app)
	gof.CurrentApp = app
}
Ejemplo n.º 5
0
Archivo: init.go Proyecto: xianmau/go2o
func Init(app gof.App) {
	dps.Init(app)
}