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 { get {
url: {{urlv2}}/api/notify/materialperday url: {{urlv2}}/api/notify/toomanyerrors
body: none body: none
auth: inherit 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 { get {
url: url: {{url}}/lst/api/logistics/getsscc
body: none body: none
auth: inherit auth: inherit
} }
settings { settings {
encodeUrl: true encodeUrl: true
timeout: 0
} }

View File

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

View File

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

View File

@@ -43,6 +43,10 @@ export const initializeProdPool = async () => {
"server", "server",
`The sql ${dbServer[0].value} is not reachable` `The sql ${dbServer[0].value} is not reachable`
); );
closePool()
setTimeout(() => {
initializeProdPool();
}, 2*1000);
return { return {
success: false, success: false,
message: `The sql ${dbServer[0].value} is not reachable`, message: `The sql ${dbServer[0].value} is not reachable`,
@@ -106,7 +110,16 @@ export const initializeProdPool = async () => {
error error
)}, "There was an error connecting to the pool."` )}, "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", "server",
`The sql ${dbServer[0].value} is not connected` `The sql ${dbServer[0].value} is not connected`
); );
return { return {
success: false, success: false,
message: `The sql ${dbServer[0].value} is not not connected`, message: `The sql ${dbServer[0].value} is not not connected`,