@ -9,9 +9,11 @@ import (
"net"
"net"
"net/http"
"net/http"
"net/http/fcgi"
"net/http/fcgi"
"strings"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)
)
func runHTTP ( network , listenAddr , name string , m http . Handler ) error {
func runHTTP ( network , listenAddr , name string , m http . Handler ) error {
@ -48,7 +50,12 @@ func runFCGI(network, listenAddr, name string, m http.Handler) error {
fcgiServer := graceful . NewServer ( network , listenAddr , name )
fcgiServer := graceful . NewServer ( network , listenAddr , name )
err := fcgiServer . ListenAndServe ( func ( listener net . Listener ) error {
err := fcgiServer . ListenAndServe ( func ( listener net . Listener ) error {
return fcgi . Serve ( listener , m )
return fcgi . Serve ( listener , http . HandlerFunc ( func ( resp http . ResponseWriter , req * http . Request ) {
if setting . AppSubURL != "" {
req . URL . Path = strings . TrimPrefix ( req . URL . Path , setting . AppSubURL )
}
m . ServeHTTP ( resp , req )
} ) )
} )
} )
if err != nil {
if err != nil {
log . Fatal ( "Failed to start FCGI main server: %v" , err )
log . Fatal ( "Failed to start FCGI main server: %v" , err )