diff --git a/cts/service/index.js b/cts/service/index.js index be5fedc..6cfdb14 100644 --- a/cts/service/index.js +++ b/cts/service/index.js @@ -15,8 +15,6 @@ */ "use strict"; -// require('dotenv').config(); - const Hapi = require("@hapi/hapi"), H2o2 = require("@hapi/h2o2"), Inert = require("@hapi/inert"), @@ -67,7 +65,8 @@ const provision = async () => { } }; - await waitPort({host: process.env.DB_HOST, port: 3306}); + const DB_HOST = (process.env.DB_HOST || "rdbms"); + await waitPort({host: DB_HOST, port: 3306}); const db = await require("./lib/db")(); @@ -305,4 +304,4 @@ process.on( } ); -provision(); +provision(); \ No newline at end of file diff --git a/cts/service/knexfile.js b/cts/service/knexfile.js index 06990a2..96a16ae 100644 --- a/cts/service/knexfile.js +++ b/cts/service/knexfile.js @@ -13,24 +13,33 @@ See the License for the specific language governing permissions and limitations under the License. */ +const DB_HOST = (process.env.DB_HOST || "rdbms"); +const DB_NAME = (process.env.DB_NAME || "catapult_player"); +const DB_USERNAME = (process.env.DB_USERNAME || "catapult"); +const DB_PASSWORD = (process.env.DB_PASSWORD || "quartz"); + const Hoek = require("@hapi/hoek"), waitPort = require("wait-port"), { - MYSQL_HOST: HOST = process.env.DB_HOST, + // MYSQL_HOST: HOST = "rdbms", MYSQL_HOST_FILE: HOST_FILE, - DATABASE_USER: USER = process.env.DB_USER, + // DATABASE_USER: USER = "catapult", DATABASE_USER_FILE: USER_FILE, - DATABASE_USER_PASSWORD: PASSWORD = process.env.DB_PASSWORD, + // DATABASE_USER_PASSWORD: DB_PASSWORD, DATABASE_USER_PASSWORD_FILE: PASSWORD_FILE, - DATABASE_NAME: DB = process.env.DB_DATABASE_NAME, + // DATABASE_NAME: DB = "catapult_player", DATABASE_NAME_FILE: DB_FILE, } = process.env; module.exports = async () => { - const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST, - user = USER_FILE ? fs.readFileSync(USER_FILE) : USER, - password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD, - database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; + // const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST, + // user = USER_FILE ? fs.readFileSync(USER_FILE) : USER, + // password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD, + // database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; + const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : DB_HOST, + user = USER_FILE ? fs.readFileSync(USER_FILE) : DB_USERNAME, + password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DB_PASSWORD, + database = DB_FILE ? fs.readFileSync(DB_FILE) : DB_NAME; await waitPort({host, port: 3306}); @@ -89,4 +98,4 @@ module.exports = async () => { return result; } }; -}; +}; \ No newline at end of file diff --git a/player/service/index.js b/player/service/index.js index 689dfe2..96a8146 100644 --- a/player/service/index.js +++ b/player/service/index.js @@ -30,11 +30,10 @@ const Hapi = require("@hapi/hapi"), TOKEN_SECRET, API_KEY, API_SECRET, - PLAYER_API_ROOT, - MYSQL_HOST + PLAYER_API_ROOT } = process.env; -const rootPath = (PLAYER_API_ROOT || ""); +const rootPath = (process.env.PLAYER_API_ROOT || ""); const provision = async () => { const server = Hapi.server( @@ -66,7 +65,8 @@ const provision = async () => { } }; - await waitPort({host: MYSQL_HOST, port: 3306}); + const DB_HOST = (process.env.DB_HOST || "rdbms"); + await waitPort({host: DB_HOST, port: 3306}); const db = await require("./lib/db")(); diff --git a/player/service/knexfile.js b/player/service/knexfile.js index 35939aa..3e3b5c0 100644 --- a/player/service/knexfile.js +++ b/player/service/knexfile.js @@ -13,24 +13,35 @@ See the License for the specific language governing permissions and limitations under the License. */ + +const DB_HOST = (process.env.DB_HOST || "rdbms"); +const DB_NAME = (process.env.DB_NAME || "catapult_player"); +const DB_USERNAME = (process.env.DB_USERNAME || "catapult"); +const DB_PASSWORD = (process.env.DB_PASSWORD || "quartz"); + const Hoek = require("@hapi/hoek"), waitPort = require("wait-port"), { - MYSQL_HOST, + // MYSQL_HOST: HOST = "rdbms", MYSQL_HOST_FILE: HOST_FILE, - DATABASE_USER, + // DATABASE_USER: USER = "catapult", DATABASE_USER_FILE: USER_FILE, - DATABASE_USER_PASSWORD, + // DATABASE_USER_PASSWORD: DB_PASSWORD, DATABASE_USER_PASSWORD_FILE: PASSWORD_FILE, - DATABASE_NAME, + // DATABASE_NAME: DB = "catapult_player", DATABASE_NAME_FILE: DB_FILE, } = process.env; module.exports = async () => { - const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : MYSQL_HOST, - user = USER_FILE ? fs.readFileSync(USER_FILE) : DATABASE_USER, - password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DATABASE_USER_PASSWORD, - database = DB_FILE ? fs.readFileSync(DB_FILE) : DATABASE_NAME; + // const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : HOST, + // user = USER_FILE ? fs.readFileSync(USER_FILE) : USER, + // password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : PASSWORD, + // database = DB_FILE ? fs.readFileSync(DB_FILE) : DB; + const host = HOST_FILE ? fs.readFileSync(HOST_FILE) : DB_HOST, + user = USER_FILE ? fs.readFileSync(USER_FILE) : DB_USERNAME, + password = PASSWORD_FILE ? fs.readFileSync(PASSWORD_FILE) : DB_PASSWORD, + database = DB_FILE ? fs.readFileSync(DB_FILE) : DB_NAME; + await waitPort({host, port: 3306});