summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorOdin Ugedal <odin@ugedal.com>2016-08-11 23:46:33 +0200
committer无闻 <u@gogs.io>2016-08-11 14:46:33 -0700
commit1dd003bd4c88f6125ec49286c9feab1f7d9b5a82 (patch)
tree1ee0c7f67c82fc92f1a4494e0582c0f568b3f42d /modules/setting
parent70fbcd2f27a027477dd18aef0d0f216bf0fb8230 (diff)
downloadgitea-1dd003bd4c88f6125ec49286c9feab1f7d9b5a82.tar.gz
gitea-1dd003bd4c88f6125ec49286c9feab1f7d9b5a82.zip
Add initial support for unix sockets (#2852)
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/setting.go37
1 files changed, 24 insertions, 13 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index a51cbf53be..559ff088cb 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -12,6 +12,7 @@ import (
"path"
"path/filepath"
"runtime"
+ "strconv"
"strings"
"time"
@@ -31,9 +32,10 @@ import (
type Scheme string
const (
- HTTP Scheme = "http"
- HTTPS Scheme = "https"
- FCGI Scheme = "fcgi"
+ HTTP Scheme = "http"
+ HTTPS Scheme = "https"
+ FCGI Scheme = "fcgi"
+ UNIX_SOCKET Scheme = "unix"
)
type LandingPage string
@@ -58,16 +60,17 @@ var (
AppDataPath string
// Server settings
- Protocol Scheme
- Domain string
- HttpAddr, HttpPort string
- LocalURL string
- OfflineMode bool
- DisableRouterLog bool
- CertFile, KeyFile string
- StaticRootPath string
- EnableGzip bool
- LandingPageUrl LandingPage
+ Protocol Scheme
+ Domain string
+ HttpAddr, HttpPort string
+ LocalURL string
+ OfflineMode bool
+ DisableRouterLog bool
+ CertFile, KeyFile string
+ StaticRootPath string
+ EnableGzip bool
+ LandingPageUrl LandingPage
+ UnixSocketPermission uint32
SSH struct {
Disabled bool `ini:"DISABLE_SSH"`
@@ -367,11 +370,19 @@ func NewContext() {
KeyFile = sec.Key("KEY_FILE").String()
} else if sec.Key("PROTOCOL").String() == "fcgi" {
Protocol = FCGI
+ } else if sec.Key("PROTOCOL").String() == "unix" {
+ Protocol = UNIX_SOCKET
}
Domain = sec.Key("DOMAIN").MustString("localhost")
HttpAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
HttpPort = sec.Key("HTTP_PORT").MustString("3000")
LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(string(Protocol) + "://localhost:" + HttpPort + "/")
+ UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
+ UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
+ if err != nil || UnixSocketPermissionParsed > 0777 {
+ log.Fatal(4, "Fail to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
+ }
+ UnixSocketPermission = uint32(UnixSocketPermissionParsed)
OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)