Skip to content

Make the Xvfb startup timeout configurable. #298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion service.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type FrameBufferOptions struct {
// ScreenSize is the option for the frame buffer screen size.
// This is of the form "{width}x{height}[x{depth}]". For example: "1024x768x24"
ScreenSize string
// XvfbTimeout is the duratin of time that we'll allow for Xvfb to startup.
XvfbTimeout time.Duration
}

// StartFrameBufferWithOptions causes an X virtual frame buffer to start before
Expand Down Expand Up @@ -364,6 +366,12 @@ func NewFrameBufferWithOptions(options FrameBufferOptions) (*FrameBuffer, error)
ch <- resp{s, err}
}()

// Give a reasonable default timeout if not specified.
timeout := 3 * time.Second
if options.XvfbTimeout > 0 {
timeout = options.XvfbTimeout
}

var display string
select {
case resp := <-ch:
Expand All @@ -374,7 +382,7 @@ func NewFrameBufferWithOptions(options FrameBufferOptions) (*FrameBuffer, error)
if _, err := strconv.Atoi(display); err != nil {
return nil, errors.New("Xvfb did not print the display number")
}
case <-time.After(3 * time.Second):
case <-time.After(timeout):
return nil, errors.New("timeout waiting for Xvfb")
}

Expand Down