Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

DB Server Connection Other than localhost #199

Closed
jayaruvan opened this issue Apr 10, 2018 · 3 comments
Closed

DB Server Connection Other than localhost #199

jayaruvan opened this issue Apr 10, 2018 · 3 comments

Comments

@jayaruvan
Copy link

I am having common postgre server
I have changed config/local.js to below

Scenario 1
models: {
connection: process.env.DB_ADAPTER || 'postgres',
},

as well as (scenario2)

models: {
connection: 'postgresql://konga:konga@192.168.10.102:5432/konga',
},

But "npm start" fails to conenct to db. My KONG is working fine with that external DB(with seperate username password and database)

Can any one enlighten me? am i missing something

@jayaruvan
Copy link
Author

jayaruvan commented Apr 10, 2018

Sorry, I found the issue.
have to make changes to config/connections.js

@pantsel
Copy link
Owner

pantsel commented Apr 10, 2018

Hi @jayaruvan ,

the actuall connections settings are defined here /config/connections.js.

As you can see in the postgres block, you will need to define your db's connection settings in the environment variables DB_HOST,DB_PORT etc...

postgres: {
    adapter: 'sails-postgresql',
    host: process.env.DB_HOST || 'localhost',
    user:  process.env.DB_USER || 'postgres',
    password: process.env.DB_PASSWORD || 'admin1!',
    port: process.env.DB_PORT || 5432,
    database: process.env.DB_DATABASE ||'konga_database',
    poolSize: process.env.DB_POOLSIZE || 10,
    ssl: process.env.DB_SSL ? true : false // If set, assume it's true
  }

`

You can also define the DB_ADAPTER= 'postgres' so that you don't change anything in local.js.

To make it short, you just need to start the app with all the needed environment variables defined

DB_ADAPTER=postgres
DB_HOST=<your_db_host>
DB_PORT= <your_db_port>
DB_USER=<your_db_user>
DB_PASSWORD=<your_db_pass>
DB_DATABASE=konga_database (or whatever you want to call it)
DB_POOLSIZE=10
DB_SSL=1 (Only if you connect to you db securely)

@jayaruvan
Copy link
Author

Thank you!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants