strapi/test/helpers/restart.js

33 lines
651 B
JavaScript
Raw Normal View History

module.exports = function (rq) {
return new Promise(async (resolve) => {
const ping = async () => {
try {
await rq({
2018-06-04 14:39:26 +02:00
url: '/_health',
method: 'HEAD',
mode: 'no-cors',
json: true,
headers: {
'Content-Type': 'application/json',
'Keep-Alive': false,
}
});
return resolve();
} catch (err) {
if (err.statusCode) {
return resolve();
} else {
return setTimeout(() => {
ping();
2018-06-04 14:39:26 +02:00
}, 1000);
}
}
};
setTimeout(() => {
ping();
2018-06-04 14:39:26 +02:00
}, 1000);
});
};