Пример #1
0
func (self *GLWeb) Run(hp string) {

	log.Infoln("GLWeb Running")
	log.SetLevel(log.DebugLevel)

	self.glsroute = make(map[string]*route)
	self.gls = make(map[string]*glf)
	self.glps = make(map[string]string)

	self.loadgls()
	self.fnotify()

	log.Infoln("GLWeb ListenAndServe...")
	go func() {
		if err := http.ListenAndServe(hp, self); err != nil {
			log.Errorln("GLWeb ListenAndServe Error.", err)
		}
	}()
	signalChan := make(chan os.Signal)               //创建一个信号量的chan,缓存为1,(0,1)意义不大
	signal.Notify(signalChan, os.Interrupt, os.Kill) //让进城收集信号量。
	<-signalChan
	log.Infoln("GLWeb Stop.")

	self.fmonitor.End()
	if db != nil {
		db.Close()
	}
	for _, g := range self.gls {
		g.close()
	}
	log.Infoln("GLWeb Close")
}
Пример #2
0
Файл: t1.go Проект: nzlov/glog
func main() {
	defer glog.Close()
	glog.SetLevel(glog.DebugLevel)
	f, err := file.New("l.log")
	if err != nil {
		panic(err)
	}
	glog.Register(f)
	glog.Register(colorconsole.New(colorconsole.ShowTypeDefault))

	a()
}