ma1uta / ma1sd

Federated Matrix Identity Server (formerly fork of kamax/mxisd)
GNU Affero General Public License v3.0
167 stars 56 forks source link

[Feature] Please support PostgreSQL connections over Unix Sockets #66

Closed Higgs1 closed 4 years ago

Higgs1 commented 4 years ago

Hi!

Ma1sd is super neat, but it'd be even better if I could use unix sockets. Even just for postgresql, but ideally for all database drivers.

I recently set up a Ma1sd instance with this requirement, and I got it working (yay!). This was done in conjunction with a homeserver installation that is also connecting to the same PostgreSQL cluster.

I did this by modifying the build.gradle file. Side note: I didn't even have full access to this file, just append-write (for reasons, okay...), but I was able to get it working by appending the following:

dependencies {
  compile 'com.kohlschutter.junixsocket:junixsocket-core:2.3.2'
  compile 'com.kohlschutter.junixsocket:junixsocket-rmi:2.3.2'
}

I don't think RMI is required, but I didn't test it. Then for the config yaml, this was the entire storage section:

storage:
  backend: postgresql
  provider:
    postgresql:
      database: >-
        //file%3A%2F%2F%2Frun%2Fpostgresql%2F.s.PGSQL.5432/exampledbname?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory%24URIScheme

Where exampledbname is the name of the postgres database, and the path to the socket is /run/postgresql/.s.PGSQL.5432 (the default path after doing a fancypackaginator install-it postgresql on most *nix distros). Notes:

I'd be happy to answer questions if possible.

Thank you! :D

Higgs1 commented 4 years ago

Closing because merged :D That was quick!

It'd still be neat if some instructions about how to connect using a UNIX socket, but low priority I guess, will open another ticket later if I come up with some ideas.