Esempio n. 1
0
// start http server
func (s *Server) Start() {
	ln, err := net.Listen("tcp", s.address)
	if err != nil {
		log.Fatal("Server|Start|%s", err.Error())
	}
	s.ln = ln

	// init http server
	httpServer := &http.Server{Addr: s.address, Handler: s.Tango}

	// use global wrapper to listen server
	Wrap("Server|Listen", func() {
		if err = httpServer.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)}); err != nil {
			if s.isClose {
				return
			}
			log.Fatal("Server|Start|%s", err.Error())
		}
	})
}
Esempio n. 2
0
// open database file
func NewDatabase(file string) *Database {
	v, _, _ := sqlite3.Version()
	log.Info("Db|Connect|SQLite %s|%s", v, file)
	engine, err := xorm.NewEngine("sqlite3", file)
	if err != nil {
		log.Fatal("Db|Connect|Error|%s", err.Error())
	}
	engine.ShowDebug = true
	engine.ShowInfo = false
	//engine.SetLogger(nil)
	return &Database{engine}
}