fragmenta / fragmenta-cms

A user-friendly CMS written in Go (golang)
http://fragmenta.eu
MIT License
586 stars 70 forks source link

DB connection #4

Closed chasseurmic closed 8 years ago

chasseurmic commented 8 years ago

I have my DB running in a separate instance. I cannot find a way to define the connection string. It always tries to connect to localhost. Where can I find some help?

kennygrant commented 8 years ago

Which db are you using, and do you just need host and port?

chasseurmic commented 8 years ago

Yeah, sorry... I'm using Postgres in a Docker container. And yes, I only need host and port. I've tried using in the fragmenta.json file something like:

"db": "postgres://192.168.99.100:32768/fragmenta-demo_development",

but to no avail...

kennygrant commented 8 years ago

I've adjusted things slightly, so you can now use these keys in your config (optionally):

db_host, db_port, db_params to supply host port, and optionally some more config params to psql.

SSL is disabled by default due to localhost being the default, if you need further setup of that see the psql driver options, and put these in to the params string, which is appended to the connection string and can contain multiple options separated by spaces. You may need sslmode and friends if using tls connections. See https://godoc.org/github.com/lib/pq.

I'm afraid I haven't sorted out how best to pull updates to local copies of the CMS while in development, but if you pull a new copy you should see the change (or just adjust your local copy). The change is in this commit:

https://github.com/fragmenta/fragmenta-cms/commit/1693ff3207b534dfa0c30caebf85a83faa69ecd9

and you will need to get a newer query library as I adjusted the drivers to pass through more information:

go get -u github.com/fragmenta/query

then rebuild your app and you should be able to use new configs. Let me know how you get on.

chasseurmic commented 8 years ago

Thank you! It works like a charm. :+1:

kennygrant commented 8 years ago

Thanks for the report, other feedback or ideas is welcome.