summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2015-03-13 22:19:50 -0400
committer无闻 <u@gogs.io>2015-03-13 22:19:50 -0400
commit8238c28c3150d28ed69d1d324604ed013e5c5c93 (patch)
tree26a16eae6ecb3c4bb58bc6ddae776cfadebb2be1
parent08cd20bad97a0b69709352229d8ba585e8fd774a (diff)
parent2bfe2ddb6dcc9ed3e8e4ca7f04f1b86a3d106a6d (diff)
downloadgitea-8238c28c3150d28ed69d1d324604ed013e5c5c93.tar.gz
gitea-8238c28c3150d28ed69d1d324604ed013e5c5c93.zip
Merge pull request #1045 from tomcatzh/master
Add mysql unix socket support.
-rw-r--r--models/models.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/models/models.go b/models/models.go
index a9436fca85..b7986fed11 100644
--- a/models/models.go
+++ b/models/models.go
@@ -89,8 +89,13 @@ func getEngine() (*xorm.Engine, error) {
cnnstr := ""
switch DbCfg.Type {
case "mysql":
- cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8",
- DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
+ if DbCfg.Host[0] == '/' { // looks like a unix socket
+ cnnstr = fmt.Sprintf("%s:%s@unix(%s)/%s?charset=utf8",
+ DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
+ } else {
+ cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8",
+ DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
+ }
case "postgres":
var host, port = "127.0.0.1", "5432"
fields := strings.Split(DbCfg.Host, ":")