mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 13:10:54 +00:00
add fcgi support
This commit is contained in:
parent
10e7dc856b
commit
b8e7a46fc1
20
beego.go
20
beego.go
@ -5,7 +5,9 @@ import (
|
|||||||
"github.com/astaxie/session"
|
"github.com/astaxie/session"
|
||||||
_ "github.com/astaxie/session/providers/memory"
|
_ "github.com/astaxie/session/providers/memory"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/fcgi"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -30,6 +32,7 @@ var (
|
|||||||
SessionProvider string // default session provider memory
|
SessionProvider string // default session provider memory
|
||||||
SessionName string // sessionName cookie's name
|
SessionName string // sessionName cookie's name
|
||||||
SessionGCMaxLifetime int64 // session's gc maxlifetime
|
SessionGCMaxLifetime int64 // session's gc maxlifetime
|
||||||
|
UseFcgi bool
|
||||||
|
|
||||||
GlobalSessions *session.Manager //GlobalSessions
|
GlobalSessions *session.Manager //GlobalSessions
|
||||||
)
|
)
|
||||||
@ -55,6 +58,7 @@ func init() {
|
|||||||
SessionProvider = "memory"
|
SessionProvider = "memory"
|
||||||
SessionName = "beegosessionID"
|
SessionName = "beegosessionID"
|
||||||
SessionGCMaxLifetime = 3600
|
SessionGCMaxLifetime = 3600
|
||||||
|
UseFcgi = false
|
||||||
} else {
|
} else {
|
||||||
HttpAddr = AppConfig.String("httpaddr")
|
HttpAddr = AppConfig.String("httpaddr")
|
||||||
if v, err := AppConfig.Int("httpport"); err != nil {
|
if v, err := AppConfig.Int("httpport"); err != nil {
|
||||||
@ -109,6 +113,11 @@ func init() {
|
|||||||
} else {
|
} else {
|
||||||
SessionGCMaxLifetime = 3600
|
SessionGCMaxLifetime = 3600
|
||||||
}
|
}
|
||||||
|
if ar, err := AppConfig.Bool("usefcgi"); err != nil {
|
||||||
|
UseFcgi = false
|
||||||
|
} else {
|
||||||
|
UseFcgi = ar
|
||||||
|
}
|
||||||
}
|
}
|
||||||
StaticDir["/static"] = "static"
|
StaticDir["/static"] = "static"
|
||||||
|
|
||||||
@ -127,7 +136,16 @@ func NewApp() *App {
|
|||||||
|
|
||||||
func (app *App) Run() {
|
func (app *App) Run() {
|
||||||
addr := fmt.Sprintf("%s:%d", HttpAddr, HttpPort)
|
addr := fmt.Sprintf("%s:%d", HttpAddr, HttpPort)
|
||||||
err := http.ListenAndServe(addr, app.Handlers)
|
var err error
|
||||||
|
if UseFcgi {
|
||||||
|
l, e := net.Listen("tcp", addr)
|
||||||
|
if e != nil {
|
||||||
|
BeeLogger.Fatal("Listen: ", e)
|
||||||
|
}
|
||||||
|
err = fcgi.Serve(l, app.Handlers)
|
||||||
|
} else {
|
||||||
|
err = http.ListenAndServe(addr, app.Handlers)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
BeeLogger.Fatal("ListenAndServe: ", err)
|
BeeLogger.Fatal("ListenAndServe: ", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user