mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 02:10:40 +00:00
Add mysql unix socket support.
If the host setting looks like a unix socket (leading by char '/'), will use unix(host) as connection string
This commit is contained in:
parent
b72e75e522
commit
2bfe2ddb6d
1 changed files with 7 additions and 2 deletions
|
@ -89,8 +89,13 @@ func getEngine() (*xorm.Engine, error) {
|
||||||
cnnstr := ""
|
cnnstr := ""
|
||||||
switch DbCfg.Type {
|
switch DbCfg.Type {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
|
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",
|
cnnstr = fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8",
|
||||||
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
|
DbCfg.User, DbCfg.Passwd, DbCfg.Host, DbCfg.Name)
|
||||||
|
}
|
||||||
case "postgres":
|
case "postgres":
|
||||||
var host, port = "127.0.0.1", "5432"
|
var host, port = "127.0.0.1", "5432"
|
||||||
fields := strings.Split(DbCfg.Host, ":")
|
fields := strings.Split(DbCfg.Host, ":")
|
||||||
|
|
Loading…
Reference in a new issue