Browse Source

Merge pull request #602 from andyleap/fcgi

Add basic FCGI support
无闻 10 năm trước cách đây
mục cha
commit
6588ce52fe
2 tập tin đã thay đổi với 7 bổ sung0 xóa
  1. 3 0
      cmd/web.go
  2. 4 0
      modules/setting/setting.go

+ 3 - 0
cmd/web.go

@@ -9,6 +9,7 @@ import (
 	"html/template"
 	"io/ioutil"
 	"net/http"
+	"net/http/fcgi"
 	"os"
 	"path"
 	"strings"
@@ -416,6 +417,8 @@ func runWeb(*cli.Context) {
 		err = http.ListenAndServe(listenAddr, m)
 	case setting.HTTPS:
 		err = http.ListenAndServeTLS(listenAddr, setting.CertFile, setting.KeyFile, m)
+	case setting.FCGI:
+		err = fcgi.Serve(nil, m)
 	default:
 		log.Fatal(4, "Invalid protocol: %s", setting.Protocol)
 	}

+ 4 - 0
modules/setting/setting.go

@@ -28,6 +28,7 @@ type Scheme string
 const (
 	HTTP  Scheme = "http"
 	HTTPS Scheme = "https"
+	FCGI  Scheme = "fcgi"
 )
 
 var (
@@ -181,6 +182,9 @@ func NewConfigContext() {
 		CertFile = Cfg.MustValue("server", "CERT_FILE")
 		KeyFile = Cfg.MustValue("server", "KEY_FILE")
 	}
+	if Cfg.MustValue("server", "PROTOCOL") == "fcgi" {
+		Protocol = FCGI
+	}
 	Domain = Cfg.MustValue("server", "DOMAIN", "localhost")
 	HttpAddr = Cfg.MustValue("server", "HTTP_ADDR", "0.0.0.0")
 	HttpPort = Cfg.MustValue("server", "HTTP_PORT", "3000")