Xvfb (X virtual framebuffer) is a virtual display server that enables the user to execute graphic operations in memory without any output to a physical display. The advantage of a virtual display is that it does not require installing a graphic environment, unifies systems, does not require user authorization in OS and access to his X session.
Set up in Debian-based distribution files
sudo apt-get install xvfb
#!/bin/bash
### BEGIN INIT INFO
# Provides: foresight-xvfb
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: true
# Short-Description: Start/stop xvfb server for Foresight Analytics Platform
### END INIT INFO
#VER=1
PIDFILE=/var/run/foresight-xvfb.pid
XVFB=/usr/bin/Xvfb
XVFBARGS=":987 -screen 0 1152x864x24 -ac -dpi 96 +extension GLX +render -noreset"
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
echo -n "Stopping virtual X frame buffer: Xvfb"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
echo "."
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/Foresight-xvfb {start|stop|restart}"
exit 1
esac
exit 0
sudo chmod +x /etc/init.d/Foresight-xvfb
sudo update-rc.d Foresight-xvfb defaults
export DISPLAY=:987
sudo service Foresight-xvfb start
Restart BI server for the settings to be applied.
Set up in RedHat-based distribution files
sudo yum install xorg-x11-server-Xvfb
#!/bin/bash
#
# /etc/rc.d/init.d/Foresight-xvfb
#
# chkconfig: 345 85 28
# description: Start/stop xvfb server for Foresight Analytics Platform
# processname: Xvfb
# pidfile: /var/run/Foresight-xvfb.pid
#
. /etc/rc.d/init.d/functions
#VER=1
LOCKFILE=/var/lock/subsys/Foresight-xvfb
PIDFILE=/var/run/Foresight-xvfb.pid
XVFB=/usr/bin/Xvfb
XVFBARGS=":987 -screen 0 1152x864x24 -ac -dpi 96 +extension GLX +render -noreset"
case "$1" in
start)
[ -x $XVFB ] || exit 5
echo -n "Starting virtual X frame buffer: Xvfb"
PID=`pidofproc -p $PIDFILE foresight-xvfb`
if [[ (-z $PID) || ($PID -eq 0) ]]; then
$XVFB $XVFBARGS & echo $! > $PIDFILE
fi
RETVAL=$?
echo "."
[ $RETVAL -eq 0 ] && touch $LOCKFILE
;;
stop)
echo -n "Stopping virtual X frame buffer: Xvfb"
killproc -p $PIDFILE $XVFB
RETVAL=$?
echo "."
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
;;
restart)
$0 stop
$0 start
;;
status)
status -p $PIDFILE $XVFB
;;
*)
echo "Usage: /etc/init.d/Foresight-xvfb {start|stop|restart|status}"
exit 1
esac
exit $?
The loading priority for Foresight-xvfb must be higher than that of httpd (the number is less). To do this, compare the second number in the # chkconfig script comments: 345 85 28 and the httpd script.
sudo chmod +x /etc/init.d/Foresight-xvfb
export DISPLAY=:987
sudo chkconfig --add Foresight-xvfb
sudo chkconfig Foresight-xvfb on
sudo service Foresight-xvfb start
Restart BI server for the settings to be applied.
If an OS uses the startup system that is different from SysV, Xvfb as a service can also be set up as follows:
Set up for OS with the Upstart startup system
Create a task file /etc/init/foresight-xvfb.conf with the contents:
# xvfb - X Virtual Frame Buffer
description "X Virtual Frame Buffer"
start on runlevel [2345]
script
Xvfb :987 -screen 0 1152x864x24 -ac -dpi 96 +extension GLX +render -noreset
end script
Start the task by executing the command:
sudo start foresight-xvfb
Set up for OS with the systemd startup system
[Unit]
Description=X Virtual Frame Buffer
Before=httpd.target
[Service]
ExecStart=/usr/bin/Xvfb :987 -screen 0 1152x864x24 -ac -dpi 96 +extension GLX +render -noreset
Type=simple
PIDFile=/var/run/foresight-xvfb.pid
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable foresight-xvfb
sudo systemctl start foresight-xvfb
See also: