Ubuntu Server 16.04 em execução no VirtualBox
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install xvfb dbus-x11 google-chrome-stable
$xvfb-run -a --server-args='-screen 0, 1024x768x16' google-chrome -start-maximized http://example.com > /dev/null &
$ ps auxx | grep Xvfb
user 1355 1.2 1.6 174992 33808 ? S 13:21 0:30 Xvfb :99 -screen 0, 1024x768x16 -nolisten tcp -auth /tmp/xvfb-run.adDyGd/Xauthority
$ cat /tmp/xvfb-run.adDyGd/Xauthority
user99MIT-MAGIC-COOKIE-1��gj��/�������auser@user:~$
$ xdpyinfo -display :99
No protocol specified
xdpyinfo: unable to open display ":99".
Iniciando o Xvfb manualmente e definindo o número de exibição antes de executar o chrome, funciona. No entanto xvfb-run não.
Xvfb manualmente
$ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install xvfb dbus-x11 google-chrome-stable
$ Xvfb :99 -screen 0 1024x768x24 > /dev/null &
$ xdpyinfo -display :99
name of display: :99
version number: 11.0
vendor string: The X.Org Foundation
vendor release number: 11803000
X.Org version: 1.18.3
maximum request size: 16777212 bytes
motion buffer size: 256
bitmap unit, bit order, padding: 32, LSBFirst, 32
image byte order: LSBFirst
number of supported pixmap formats: 6
supported pixmap formats:
depth 1, bits_per_pixel 1, scanline_pad 32
depth 4, bits_per_pixel 8, scanline_pad 32
depth 8, bits_per_pixel 8, scanline_pad 32
depth 16, bits_per_pixel 16, scanline_pad 32
depth 24, bits_per_pixel 32, scanline_pad 32
depth 32, bits_per_pixel 32, scanline_pad 32
keycode range: minimum 8, maximum 255
focus: PointerRoot
number of extensions: 25
...
default screen number: 0
number of screens: 1
screen #0:
dimensions: 1024x768 pixels (260x195 millimeters)
resolution: 100x100 dots per inch
depths (6): 24, 1, 4, 8, 16, 32
root window id: 0x25c
depth of root window: 24 planes
number of colormaps: minimum 1, maximum 1
default colormap: 0x20
default number of colormap cells: 256
preallocated pixels: black 0, white 16777215
options: backing-store WHEN MAPPED, save-unders NO
largest cursor: 1024x768
current input event mask: 0x0
number of visuals: 240
default visual id: 0x21
$ export DISPLAY=:99 && google-chrome -start-maximized http://example.com > /dev/null &
$ ps auxx | grep 'chrome\|Xvfb' | grep -v grep
ubuntu 14843 0.0 0.4 193320 35308 pts/0 Sl 17:57 0:00 Xvfb :99 -screen 0 1024x768x24
ubuntu 14856 0.2 1.3 569044 108484 pts/0 Sl 17:58 0:01 /opt/google/chrome/chrome -start-maximized http://example.com
ubuntu 14868 0.0 0.6 358448 49424 pts/0 S 17:58 0:00 /opt/google/chrome/chrome --type=zygote
ubuntu 14869 0.0 0.1 142096 9596 pts/0 S 17:58 0:00 /opt/google/chrome/nacl_helper
ubuntu 14872 0.0 0.1 358448 11012 pts/0 S 17:58 0:00 /opt/google/chrome/chrome --type=zygote
ubuntu 14960 0.0 0.7 446888 64060 pts/0 Sl 17:58 0:00 /opt/google/chrome/chrome --type=gpu-process --channel=14856.0.2123468494 --window-depth=24 --supports-dual-gpus=false --gpu-driver-bug-workarounds=4,53 --disable-accelerated-video-decode --gpu-vendor-id=0x1013 --gpu-device-id=0x00b8 --gpu-driver-vendor --gpu-driver-version --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd
com xvfb-run
$ xvfb-run -a --server-args='-screen 0, 1024x768x24' google-chrome -start-maximized http://example.com > /dev/null &
$ ps auxx | grep 'chrome\|Xvfb' | grep -v grep
ubuntu 1196 0.0 0.0 4508 1644 pts/0 S 18:15 0:00 /bin/sh /usr/bin/xvfb-run -a --server-args=-screen 0, 1024x768x24 google-chrome -start-maximized http://example.com
ubuntu 1208 0.0 0.4 193192 35572 pts/0 Sl 18:15 0:00 Xvfb :99 -screen 0, 1024x768x24 -nolisten tcp -auth /tmp/xvfb-run.8pPvAX/Xauthority
ubuntu 1213 0.4 1.3 619068 106576 pts/0 Sl 18:15 0:00 /opt/google/chrome/chrome -start-maximized http://example.com
ubuntu 1224 0.0 0.5 358448 47768 pts/0 S 18:15 0:00 /opt/google/chrome/chrome --type=zygote
ubuntu 1225 0.0 0.1 142128 9600 pts/0 S 18:15 0:00 /opt/google/chrome/nacl_helper
ubuntu 1228 0.0 0.1 358448 10492 pts/0 S 18:15 0:00 /opt/google/chrome/chrome --type=zygote
ubuntu 1440 0.0 0.7 738140 62828 pts/0 Sl 18:15 0:00 /opt/google/chrome/chrome --type=renderer --lang=en-US --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-pinch --num-raster-threads=1 --content-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --video-image-texture-target=3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553,3553 --disable-accelerated-video-decode --disable-webrtc-hw-encoding --disable-gpu-compositing --channel=1213.0.1322123415 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd
$ xdpyinfo -display :99
No protocol specified
xdpyinfo: unable to open display ":99".
Observe a diferença no comando Xvfb que o xvfb-run usa:
Xvfb :99 -screen 0, 1024x768x24 -nolisten tcp -auth /tmp/xvfb-run.8pPvAX/Xauthority
No entanto, esse não é o problema, já que executá-lo sozinho e obter as informações de exibição funcionam bem.
Tags virtualbox 16.04 xvfb