3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 13:29:27 +01:00

Merge pull request #1016 from ajaspers/mysql

Add support for Unix domain sockets.
This commit is contained in:
Shivaram Lingamneni 2020-05-16 22:19:43 -07:00 committed by GitHub
commit 1ab06949bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 5 deletions

View File

@ -663,8 +663,9 @@ datastore:
mysql:
enabled: false
host: "localhost"
# port is unnecessary for connections via unix domain socket:
#port: 3306
port: 3306
# if socket-path is set, it will be used instead of host:port
#socket-path: "/var/run/mysqld/mysqld.sock"
user: "oragono"
password: "hunter2"
history-database: "oragono_history"

View File

@ -12,6 +12,7 @@ type Config struct {
Enabled bool
Host string
Port int
SocketPath string `yaml:"socket-path"`
User string
Password string
HistoryDatabase string `yaml:"history-database"`

View File

@ -88,7 +88,9 @@ func (mysql *MySQL) getExpireTime() (expireTime time.Duration) {
func (m *MySQL) Open() (err error) {
var address string
if m.config.Port != 0 {
if m.config.SocketPath != "" {
address = fmt.Sprintf("unix(%s)", m.config.SocketPath)
} else if m.config.Port != 0 {
address = fmt.Sprintf("tcp(%s:%d)", m.config.Host, m.config.Port)
}

View File

@ -684,8 +684,9 @@ datastore:
mysql:
enabled: false
host: "localhost"
# port is unnecessary for connections via unix domain socket:
#port: 3306
port: 3306
# if socket-path is set, it will be used instead of host:port
#socket-path: "/var/run/mysqld/mysqld.sock"
user: "oragono"
password: "hunter2"
history-database: "oragono_history"