Method: Headless#initialize
- Defined in:
- lib/headless.rb
#initialize(options = {}) ⇒ Headless
Creates a new headless server, but does NOT switch to it immediately. Call #start for that
List of available options:
-
display
(default 99) - what display number to listen to; -
reuse
(default true) - if given display server already exists, should we use it or try another? -
autopick
(default true if display number isn’t explicitly set) - if Headless should automatically pick a display, or fail if the given one is not available. -
dimensions
(default 1280x1024x24) - display dimensions and depth. Not all combinations are possible, refer to man Xvfb. -
destroy_at_exit
- if a display is started but not stopped, should it be destroyed when the script finishes? (default true unless reuse is true and a server is already running) -
xvfb_launch_timeout
- how long should we wait for Xvfb to open a display, before assuming that it is frozen (in seconds, default is 10) -
video
- options to be passed to the ffmpeg video recorder. See Headless::VideoRecorder#initialize for documentation
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/headless.rb', line 77 def initialize( = {}) CliUtil.ensure_application_exists!('Xvfb', 'Xvfb not found on your system') @display = .fetch(:display, DEFAULT_DISPLAY_NUMBER).to_i @xvfb_launch_timeout = .fetch(:xvfb_launch_timeout, DEFAULT_XVFB_LAUNCH_TIMEOUT).to_i @autopick_display = .fetch(:autopick, !.key?(:display)) @reuse_display = .fetch(:reuse, true) @dimensions = .fetch(:dimensions, DEFAULT_DISPLAY_DIMENSIONS) @video_capture_options = .fetch(:video, {}) already_running = xvfb_running? rescue false @destroy_at_exit = .fetch(:destroy_at_exit, !(@reuse_display && already_running)) @pid = nil # the pid of the running Xvfb process # FIXME Xvfb launch should not happen inside the constructor attach_xvfb end |