Skip to content

Commit

Permalink
feat(cli): add startServerReadyTimeout option (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Mar 19, 2020
1 parent 5de8ec8 commit 8b0fea7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/cli/src/collect/collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ function buildCommand(yargs) {
type: 'string',
default: 'listen|ready',
},
startServerReadyTimeout: {
description: 'The number of milliseconds to wait for the server to start before continuing',
type: 'number',
default: 10000,
},
settings: {description: 'The Lighthouse settings and flags to use when collecting'},
numberOfRuns: {
alias: 'n',
Expand Down Expand Up @@ -115,13 +120,13 @@ async function startServerAndDetermineUrls(options) {
const {child, patternMatch, stdout, stderr} = await runCommandAndWaitForPattern(
options.startServerCommand,
regexPattern,
{timeout: 10000}
{timeout: options.startServerReadyTimeout}
);
process.stdout.write(`Started a web server with "${options.startServerCommand}"...\n`);
close = () => killProcessTree(child.pid);

if (!patternMatch) {
// This is only for readability.
// This `message` variable is only for readability.
const message = `Ensure the server prints a pattern that matches ${regexPattern} when it is ready.\n`;
process.stdout.write(`WARNING: Timed out waiting for the server to start listening.\n`);
process.stdout.write(` ${message}`);
Expand Down
1 change: 1 addition & 0 deletions types/collect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ declare global {
staticDistDir?: string;
isSinglePageApplication?: boolean;
startServerCommand?: string;
startServerReadyTimeout: number;
startServerReadyPattern: string;
chromePath?: string;
puppeteerScript?: string;
Expand Down

0 comments on commit 8b0fea7

Please sign in to comment.