mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Merge pull request #245 from Icinga/feature/add-mysql-unix-domain-socket-228
Add support mysql unix domain socket
This commit is contained in:
commit
9570975494
2 changed files with 10 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ Data resource where IcingaDB stores synced data and historical events.
|
|||
|
||||
Option | Description
|
||||
-------------------------|-----------------------------------------------
|
||||
host | **Optional.** MySQL host. Defaults to `127.0.0.1`.
|
||||
host | **Optional.** MySQL host or absolute Unix socket path. Defaults to `127.0.0.1`.
|
||||
port | **Optional.** MySQL port. Defaults to `3306`.
|
||||
database | **Optional.** MySQL database. Defaults to `icingadb`.
|
||||
user | **Optional.** MySQL username.
|
||||
|
|
|
|||
13
main.go
13
main.go
|
|
@ -66,6 +66,7 @@ import (
|
|||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
|
@ -106,10 +107,14 @@ func main() {
|
|||
|
||||
redisConn := connection.NewRDBWrapper(redisInfo.Host+":"+redisInfo.Port, redisInfo.Password, redisInfo.PoolSize)
|
||||
|
||||
mysqlConn, err := connection.NewDBWrapper(
|
||||
mysqlInfo.User+":"+mysqlInfo.Password+"@tcp("+mysqlInfo.Host+":"+mysqlInfo.Port+")/"+mysqlInfo.Database,
|
||||
mysqlInfo.MaxOpenConns,
|
||||
)
|
||||
var dbDSN string
|
||||
if filepath.IsAbs(mysqlInfo.Host) {
|
||||
dbDSN = mysqlInfo.User+":"+mysqlInfo.Password+"@unix("+mysqlInfo.Host+")/"+mysqlInfo.Database
|
||||
} else {
|
||||
dbDSN = mysqlInfo.User+":"+mysqlInfo.Password+"@tcp("+mysqlInfo.Host+":"+mysqlInfo.Port+")/"+mysqlInfo.Database
|
||||
}
|
||||
|
||||
mysqlConn, err := connection.NewDBWrapper(dbDSN, mysqlInfo.MaxOpenConns)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue