fix(sql): fix connection issues in the sql connection loosing it

This commit is contained in:
2025-12-31 07:54:26 -06:00
parent e8a2ef8b85
commit 56934216f7
6 changed files with 43 additions and 6 deletions

View File

@@ -5,7 +5,7 @@ meta {
}
get {
url: {{urlv2}}/api/notify/materialperday
url: {{urlv2}}/api/notify/toomanyerrors
body: none
auth: inherit
}

View File

@@ -0,0 +1,22 @@
meta {
name: sscc
type: http
seq: 4
}
post {
url: {{url}}/lst/old/api/logistics/getsscc
body: json
auth: inherit
}
body:json {
{
"runningNr": ""
}
}
settings {
encodeUrl: true
timeout: 0
}

View File

@@ -5,11 +5,12 @@ meta {
}
get {
url:
url: {{url}}/lst/api/logistics/getsscc
body: none
auth: inherit
}
settings {
encodeUrl: true
timeout: 0
}

View File

@@ -1,5 +1,5 @@
vars {
url: https://uslim1prod.alpla.net
url: https://day1prod.alpla.net
session_cookie:
urlv2: http://localhost:3000
jwtV2:

View File

@@ -78,7 +78,7 @@ const main = async () => {
// connect to the prod sql
console.log("Connecting to the sql server");
await initializeProdPool();
// express app
const app = express();
@@ -184,7 +184,7 @@ const main = async () => {
// swaggerUi.serve,
// swaggerUi.setup(openapiSpec, swaggerUiOptions),
// );
initializeProdPool();
setupSwagger(app, basePath)
app.use(basePath + "/d", express.static(join(__dirname, "../lstDocs/build")));
app.use(

View File

@@ -43,6 +43,10 @@ export const initializeProdPool = async () => {
"server",
`The sql ${dbServer[0].value} is not reachable`
);
closePool()
setTimeout(() => {
initializeProdPool();
}, 2*1000);
return {
success: false,
message: `The sql ${dbServer[0].value} is not reachable`,
@@ -106,7 +110,16 @@ export const initializeProdPool = async () => {
error
)}, "There was an error connecting to the pool."`
);
throw new Error("There was an error closing the sql connection");
closePool()
setTimeout(() => {
initializeProdPool();
}, 2*1000);
return {
success: true,
message: "The sql server connection has been closed",
}
//throw new Error("There was an error closing the sql connection");
}
};
@@ -176,6 +189,7 @@ export async function query(queryToRun: string, name: string) {
"server",
`The sql ${dbServer[0].value} is not connected`
);
return {
success: false,
message: `The sql ${dbServer[0].value} is not not connected`,