mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
wip - use unix socket
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
f0270dc48c
commit
4f1732f186
8
db/db.go
8
db/db.go
@ -42,6 +42,10 @@ func Db() *sql.DB {
|
|||||||
//Password(password).
|
//Password(password).
|
||||||
Logger(&logAdapter{ctx: context.Background()}).
|
Logger(&logAdapter{ctx: context.Background()}).
|
||||||
DataPath(filepath.Join(conf.Server.DataFolder, "postgres")).
|
DataPath(filepath.Join(conf.Server.DataFolder, "postgres")).
|
||||||
|
StartParameters(map[string]string{
|
||||||
|
"unix_socket_directories": "/tmp",
|
||||||
|
"unix_socket_permissions": "0700",
|
||||||
|
}).
|
||||||
BinariesPath(filepath.Join(conf.Server.CacheFolder, "postgres")),
|
BinariesPath(filepath.Join(conf.Server.CacheFolder, "postgres")),
|
||||||
)
|
)
|
||||||
if err := postgresInstance.Start(); err != nil {
|
if err := postgresInstance.Start(); err != nil {
|
||||||
@ -55,7 +59,7 @@ func Db() *sql.DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the navidrome database if it doesn't exist
|
// Create the navidrome database if it doesn't exist
|
||||||
adminPath := "postgresql://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable"
|
adminPath := "postgresql://postgres:postgres@/postgres?sslmode=disable&host=/tmp"
|
||||||
adminDB, err := sql.Open(Driver, adminPath)
|
adminDB, err := sql.Open(Driver, adminPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = postgresInstance.Stop()
|
_ = postgresInstance.Stop()
|
||||||
@ -88,7 +92,7 @@ func Db() *sql.DB {
|
|||||||
//Path = conf.Server.DbPath
|
//Path = conf.Server.DbPath
|
||||||
// Ensure client does not attempt TLS when connecting to the embedded Postgres
|
// Ensure client does not attempt TLS when connecting to the embedded Postgres
|
||||||
// and avoid shadowing the package-level Path variable.
|
// and avoid shadowing the package-level Path variable.
|
||||||
Path = "postgresql://postgres:postgres@127.0.0.1:5432/navidrome?sslmode=disable"
|
Path = "postgresql://postgres:postgres@/navidrome?sslmode=disable&host=/tmp"
|
||||||
log.Debug("Opening DataBase", "dbPath", Path, "driver", Driver)
|
log.Debug("Opening DataBase", "dbPath", Path, "driver", Driver)
|
||||||
db, err := sql.Open(Driver, Path)
|
db, err := sql.Open(Driver, Path)
|
||||||
//db.SetMaxOpenConns(max(4, runtime.NumCPU()))
|
//db.SetMaxOpenConns(max(4, runtime.NumCPU()))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user