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,8 +663,9 @@ datastore:
663 663
     mysql:
664 664
         enabled: false
665 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 669
         user: "oragono"
669 670
         password: "hunter2"
670 671
         history-database: "oragono_history"

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

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

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

@@ -88,7 +88,9 @@ func (mysql *MySQL) getExpireTime() (expireTime time.Duration) {
88 88
 
89 89
 func (m *MySQL) Open() (err error) {
90 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 94
 		address = fmt.Sprintf("tcp(%s:%d)", m.config.Host, m.config.Port)
93 95
 	}
94 96
 

+ 3
- 2
oragono.yaml View File

@@ -684,8 +684,9 @@ datastore:
684 684
     mysql:
685 685
         enabled: false
686 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 690
         user: "oragono"
690 691
         password: "hunter2"
691 692
         history-database: "oragono_history"

Loading…
Cancel
Save