MCPcopy
hub / github.com/promptfoo/promptfoo / checkServerRunning

Function checkServerRunning

src/util/server.ts:102–116  ·  view source on GitHub ↗
(port = getDefaultPort())

Source from the content-addressed store, hash-verified

100}
101
102export async function checkServerRunning(port = getDefaultPort()): Promise<boolean> {
103 logger.debug(`Checking for existing server on port ${port}...`);
104 try {
105 const response = await fetchWithProxy(`http://localhost:${port}/health`, {
106 headers: {
107 'x-promptfoo-silent': 'true',
108 },
109 });
110 const data = await response.json();
111 return data.status === 'OK' && data.version === VERSION;
112 } catch (err) {
113 logger.debug(`No existing server found - this is expected on first startup. ${String(err)}`);
114 return false;
115 }
116}
117
118export async function openBrowser(
119 browserBehavior: BrowserBehavior,

Callers 6

server.test.tsFile · 0.90
evalSetupCommandFunction · 0.90
redteamReportCommandFunction · 0.90
initCommandFunction · 0.90
redteamSetupCommandFunction · 0.90
mainFunction · 0.90

Calls 2

getDefaultPortFunction · 0.90
fetchWithProxyFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…