run() — astro Function Reference
Architecture documentation for the run() function in server-stress.js from the astro codebase.
Entity Profile
Dependency Diagram
graph TD b10e2763_a98a_e2fe_fbec_05e0586161fb["run()"] 84e8dcec_8779_ed84_459a_2c92f21c0f63["server-stress.js"] b10e2763_a98a_e2fe_fbec_05e0586161fb -->|defined in| 84e8dcec_8779_ed84_459a_2c92f21c0f63 cf992736_c919_558e_07d3_47d9dab7be64["benchmarkCannon()"] b10e2763_a98a_e2fe_fbec_05e0586161fb -->|calls| cf992736_c919_558e_07d3_47d9dab7be64 8039d01f_d3a1_3872_c4e3_a7ce4b45bf93["printResult()"] b10e2763_a98a_e2fe_fbec_05e0586161fb -->|calls| 8039d01f_d3a1_3872_c4e3_a7ce4b45bf93 style b10e2763_a98a_e2fe_fbec_05e0586161fb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmark/bench/server-stress.js lines 18–59
export async function run(projectDir, outputFile) {
const root = fileURLToPath(projectDir);
console.log('Building...');
await exec(astroBin, ['build'], {
nodeOptions: {
cwd: root,
stdio: 'inherit',
},
throwOnError: true,
});
console.log('Previewing...');
const previewProcess = await exec(astroBin, ['preview', '--port', port], {
nodeOptions: {
cwd: root,
stdio: 'inherit',
},
});
console.log('Waiting for server ready...');
await waitUntilBusy(port, { timeout: 5000 });
console.log('Running benchmark...');
const result = await benchmarkCannon();
console.log('Killing server...');
if (!previewProcess.kill('SIGTERM')) {
console.warn('Failed to kill server process id:', previewProcess.pid);
}
console.log('Writing results to', fileURLToPath(outputFile));
await fs.writeFile(outputFile, JSON.stringify(result, null, 2));
console.log('Result preview:');
console.log('='.repeat(10));
console.log(`#### Server stress\n\n`);
console.log(printResult(result));
console.log('='.repeat(10));
console.log('Done!');
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does run() do?
run() is a function in the astro codebase, defined in benchmark/bench/server-stress.js.
Where is run() defined?
run() is defined in benchmark/bench/server-stress.js at line 18.
What does run() call?
run() calls 2 function(s): benchmarkCannon, printResult.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free