mirror of
https://github.com/strapi/strapi.git
synced 2025-07-13 20:11:47 +00:00
24 lines
650 B
JavaScript
24 lines
650 B
JavaScript
const request = require('request-promise-native');
|
|
|
|
module.exports = function(initTime = 200) {
|
|
const ping = async () => {
|
|
return new Promise((resolve, reject) => {
|
|
// ping _health
|
|
request({
|
|
url: 'http://localhost:1337/_health',
|
|
method: 'HEAD',
|
|
mode: 'no-cors',
|
|
json: true,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Keep-Alive': false,
|
|
},
|
|
}).then(resolve, reject);
|
|
}).catch(() => {
|
|
return new Promise(resolve => setTimeout(resolve, 200)).then(ping);
|
|
});
|
|
};
|
|
|
|
return new Promise(resolve => setTimeout(resolve, initTime)).then(ping);
|
|
};
|