fix: refs #8657 test await printer server
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2025-02-24 14:28:29 +01:00
parent 186219f057
commit acf0f82d85
1 changed files with 18 additions and 1 deletions

View File

@ -17,7 +17,7 @@ async function init() {
});
// FIXME: Workaround to wait for loopback to be ready
app.emit('started');
await app.models.Application.status();
await getStatus();
}
async function deinit() {
@ -33,3 +33,20 @@ module.exports = {
if (require.main === module)
init();
async function getStatus() {
const MAX_ATTEMPTS = 10;
let attempts = 0;
return new Promise((resolve, reject) => {
const intervalo = setInterval(async() => {
try {
const resultado = await app.models.Application.status();
clearInterval(intervalo);
resolve(resultado);
} catch (error) {
console.log('Attempt to connect ' + attempts + '/' + MAX_ATTEMPTS);
if (attempts >= MAX_ATTEMPTS)reject(error);
}
attempts++;
}, 100);
});
}