From 341c4c5c3d3ac2909ccfc3e154f2ac79ccbe728a Mon Sep 17 00:00:00 2001 From: nh758 <10155226+nh758@users.noreply.github.com> Date: Tue, 9 Sep 2025 02:45:00 +0000 Subject: [PATCH 1/5] remove redis lib --- utils/controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/controller.js b/utils/controller.js index 07f969b..512727c 100644 --- a/utils/controller.js +++ b/utils/controller.js @@ -14,7 +14,7 @@ const Mysql = require("mysql"); const path = require("path"); // const prettyTime = require("pretty-time"); -const redis = require("redis"); +// const redis = require("redis"); // var _ = require("lodash"); const EventEmitter = require("events").EventEmitter; From d4ff0e09eff0565b78cbcc7789750188ddba07a1 Mon Sep 17 00:00:00 2001 From: nh758 <10155226+nh758@users.noreply.github.com> Date: Thu, 11 Sep 2025 01:01:13 +0000 Subject: [PATCH 2/5] Clean up logs --- utils/defaults.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/defaults.js b/utils/defaults.js index 5baa86c..17ed85a 100644 --- a/utils/defaults.js +++ b/utils/defaults.js @@ -15,6 +15,7 @@ function env(envKey, defaultValue) { if (typeof process.env[envKey] == "undefined" || process.env[envKey] == "") { return defaultValue; } + if (envKey.startsWith("MYSQL_")) return process.env[envKey]; try { return JSON.parse(process.env[envKey]); } catch (e) { @@ -24,14 +25,15 @@ function env(envKey, defaultValue) { let expectedValues = ["http"]; let isExpected = false; expectedValues.forEach((v) => { - if (process.env[envKey].indexOf("http") != -1) { + if (process.env[envKey].indexOf(v) != -1) { isExpected = true; } }); if (!isExpected) { // let's report this just in case: - console.log(e); - console.log(`process.env[${envKey}]=[${process.env[envKey]}]`); + console.log( + `Failed to parse process.env[${envKey}]=[${process.env[envKey]}] as JSON, is this expected?`, + ); } return process.env[envKey]; From 21000dbbf824879837e46efc4df598f3be539899 Mon Sep 17 00:00:00 2001 From: nh758 <10155226+nh758@users.noreply.github.com> Date: Thu, 11 Sep 2025 15:53:38 +0000 Subject: [PATCH 3/5] skip wait for redis host 'redis' --- utils/controller.js | 77 +++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/utils/controller.js b/utils/controller.js index 512727c..c8fc0d2 100644 --- a/utils/controller.js +++ b/utils/controller.js @@ -726,43 +726,46 @@ class ABServiceController extends EventEmitter { * @return {Promise} */ _waitForRedis() { - return new Promise((resolve /* , reject */) => { - var client = redis.createClient({ - host: "redis", - // port: , - // password: '' - - retry_strategy: function (options) { - // if (options.error && options.error.code === "ECONNREFUSED") { - // // End reconnecting on a specific error and flush all commands with - // // a individual error - // return new Error("The server refused the connection"); - // } - // if (options.total_retry_time > 1000 * 60 * 60) { - // // End reconnecting after a specific timeout and flush all commands - // // with a individual error - // return new Error("Retry time exhausted"); - // } - // if (options.attempt > 10) { - // // End reconnecting with built in error - // return undefined; - // } - - // console.log("... waiting for redis attempt:" + options.attempt); - // reconnect after - return Math.min(options.attempt * 200, 3000); - }, - }); - - // client.on("error", (err) => { - // console.log("... waiting for redis"); - // }); - - client.on("connect", () => { - client.quit(); - resolve(); - }); - }); + // Can't have a hard coded host for ecs. Is this even necessary, I think + // cote can handle + return new Promise((r) => r()); + // return new Promise((resolve /* , reject */) => { + // var client = redis.createClient({ + // host: "redis", + // // port: , + // // password: '' + // + // retry_strategy: function (options) { + // // if (options.error && options.error.code === "ECONNREFUSED") { + // // // End reconnecting on a specific error and flush all commands with + // // // a individual error + // // return new Error("The server refused the connection"); + // // } + // // if (options.total_retry_time > 1000 * 60 * 60) { + // // // End reconnecting after a specific timeout and flush all commands + // // // with a individual error + // // return new Error("Retry time exhausted"); + // // } + // // if (options.attempt > 10) { + // // // End reconnecting with built in error + // // return undefined; + // // } + // + // // console.log("... waiting for redis attempt:" + options.attempt); + // // reconnect after + // return Math.min(options.attempt * 200, 3000); + // }, + // }); + // + // // client.on("error", (err) => { + // // console.log("... waiting for redis"); + // // }); + // + // client.on("connect", () => { + // client.quit(); + // resolve(); + // }); + // }); } } From e163c3d038b7f4382a5c533560425c2055df05b7 Mon Sep 17 00:00:00 2001 From: "pong.promrat" Date: Wed, 4 Feb 2026 16:54:51 +0700 Subject: [PATCH 4/5] +add MySQL connection pool max size config --- utils/defaults.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/defaults.js b/utils/defaults.js index 17ed85a..48c7b49 100644 --- a/utils/defaults.js +++ b/utils/defaults.js @@ -51,6 +51,7 @@ module.exports = { user: env("MYSQL_USER", "root"), password: process.env.MYSQL_PASSWORD, database: env("MYSQL_DBPREFIX", "appbuilder"), + poolMax: env("MYSQL_POOL_MAX"), }, site: { adapter: "sails-mysql", @@ -59,6 +60,7 @@ module.exports = { user: env("MYSQL_USER", "root"), password: process.env.MYSQL_PASSWORD, database: env("MYSQL_DBADMIN", "appbuilder-admin"), + poolMax: env("MYSQL_POOL_MAX"), }, }; }, From d8a950d17e76e2168cf67c01dc7857c28586b85d Mon Sep 17 00:00:00 2001 From: "pong.promrat" Date: Wed, 4 Feb 2026 22:13:57 +0700 Subject: [PATCH 5/5] *Fix "Tarn: opt.max must be an integer > 0" error --- utils/defaults.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils/defaults.js b/utils/defaults.js index 48c7b49..0b65580 100644 --- a/utils/defaults.js +++ b/utils/defaults.js @@ -51,7 +51,9 @@ module.exports = { user: env("MYSQL_USER", "root"), password: process.env.MYSQL_PASSWORD, database: env("MYSQL_DBPREFIX", "appbuilder"), - poolMax: env("MYSQL_POOL_MAX"), + poolMax: env("MYSQL_POOL_MAX") + ? parseInt(env("MYSQL_POOL_MAX")) + : undefined, }, site: { adapter: "sails-mysql", @@ -60,7 +62,9 @@ module.exports = { user: env("MYSQL_USER", "root"), password: process.env.MYSQL_PASSWORD, database: env("MYSQL_DBADMIN", "appbuilder-admin"), - poolMax: env("MYSQL_POOL_MAX"), + poolMax: env("MYSQL_POOL_MAX") + ? parseInt(env("MYSQL_POOL_MAX")) + : undefined, }, }; },