MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / checkServer

Function checkServer

backend/integration_tests/setup/global-setup.js:13–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11 const startTime = Date.now();
12
13 const checkServer = () => {
14 const req = http.get(`http://localhost:${port}/api/health`, (res) => {
15 if (res.statusCode === 200) {
16 resolve();
17 } else {
18 if (Date.now() - startTime > timeout) {
19 reject(new Error(`Server did not start within ${timeout}ms`));
20 } else {
21 setTimeout(checkServer, 1000);
22 }
23 }
24 });
25
26 req.on('error', () => {
27 if (Date.now() - startTime > timeout) {
28 reject(new Error(`Server did not start within ${timeout}ms`));
29 } else {
30 setTimeout(checkServer, 1000);
31 }
32 });
33 };
34
35 checkServer();
36 });

Callers 1

waitForServerFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected