diff --git a/app.go b/app.go index 0a83ba41..0b89d89e 100644 --- a/app.go +++ b/app.go @@ -55,15 +55,24 @@ func (app *App) Run() { endRunning := make(chan bool, 1) if UseFcgi { - if HttpPort == 0 { - l, err = net.Listen("unix", addr) + if UseStdIo { + err = fcgi.Serve(nil, app.Handlers) // standard I/O + if err == nil { + BeeLogger.Info("Use FCGI via standard I/O") + } else { + BeeLogger.Info("Cannot use FCGI via standard I/O", err) + } } else { - l, err = net.Listen("tcp", addr) + if HttpPort == 0 { + l, err = net.Listen("unix", addr) + } else { + l, err = net.Listen("tcp", addr) + } + if err != nil { + BeeLogger.Critical("Listen: ", err) + } + err = fcgi.Serve(l, app.Handlers) } - if err != nil { - BeeLogger.Critical("Listen: ", err) - } - err = fcgi.Serve(l, app.Handlers) } else { app.Server.Addr = addr app.Server.Handler = app.Handlers diff --git a/config.go b/config.go index ef201ec6..6c121756 100644 --- a/config.go +++ b/config.go @@ -61,6 +61,7 @@ var ( SessionAutoSetCookie bool // auto setcookie SessionDomain string // the cookie domain default is empty UseFcgi bool + UseStdIo bool MaxMemory int64 EnableGzip bool // flag of enable gzip DirectoryIndex bool // flag of display directory index. default is false. @@ -241,6 +242,7 @@ func init() { SessionAutoSetCookie = true UseFcgi = false + UseStdIo = false MaxMemory = 1 << 26 //64MB