Browse Source

Merge pull request #1016 from ajaspers/mysql

Add support for Unix domain sockets.
tags/v2.1.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
1ab06949bf
No account linked to committer's email address
4 changed files with 10 additions and 5 deletions
  1. 3
    2
      conventional.yaml
  2. 1
    0
      irc/mysql/config.go
  3. 3
    1
      irc/mysql/history.go
  4. 3
    2
      oragono.yaml

+ 3
- 2
conventional.yaml View File

663
     mysql:
663
     mysql:
664
         enabled: false
664
         enabled: false
665
         host: "localhost"
665
         host: "localhost"
666
-        # port is unnecessary for connections via unix domain socket:
667
-        #port: 3306
666
+        port: 3306
667
+        # if socket-path is set, it will be used instead of host:port
668
+        #socket-path: "/var/run/mysqld/mysqld.sock"
668
         user: "oragono"
669
         user: "oragono"
669
         password: "hunter2"
670
         password: "hunter2"
670
         history-database: "oragono_history"
671
         history-database: "oragono_history"

+ 1
- 0
irc/mysql/config.go View File

12
 	Enabled         bool
12
 	Enabled         bool
13
 	Host            string
13
 	Host            string
14
 	Port            int
14
 	Port            int
15
+	SocketPath      string `yaml:"socket-path"`
15
 	User            string
16
 	User            string
16
 	Password        string
17
 	Password        string
17
 	HistoryDatabase string `yaml:"history-database"`
18
 	HistoryDatabase string `yaml:"history-database"`

+ 3
- 1
irc/mysql/history.go View File

88
 
88
 
89
 func (m *MySQL) Open() (err error) {
89
 func (m *MySQL) Open() (err error) {
90
 	var address string
90
 	var address string
91
-	if m.config.Port != 0 {
91
+	if m.config.SocketPath != "" {
92
+		address = fmt.Sprintf("unix(%s)", m.config.SocketPath)
93
+	} else if m.config.Port != 0 {
92
 		address = fmt.Sprintf("tcp(%s:%d)", m.config.Host, m.config.Port)
94
 		address = fmt.Sprintf("tcp(%s:%d)", m.config.Host, m.config.Port)
93
 	}
95
 	}
94
 
96
 

+ 3
- 2
oragono.yaml View File

684
     mysql:
684
     mysql:
685
         enabled: false
685
         enabled: false
686
         host: "localhost"
686
         host: "localhost"
687
-        # port is unnecessary for connections via unix domain socket:
688
-        #port: 3306
687
+        port: 3306
688
+        # if socket-path is set, it will be used instead of host:port
689
+        #socket-path: "/var/run/mysqld/mysqld.sock"
689
         user: "oragono"
690
         user: "oragono"
690
         password: "hunter2"
691
         password: "hunter2"
691
         history-database: "oragono_history"
692
         history-database: "oragono_history"

Loading…
Cancel
Save