Xvfb As A Service
sometimes it’s useful to run a a X app without a display to batch process something, but the app won’t run without an X server to connect to. That’s where X Virtual Frame Buffer Xvfb comes in. It’s everything an X server should be except actually displaying anything. It’s just missing one nicety, by default it doesn’t run as a service, so you’d have to bring it up and tear it back down for every instance that needs the X display. that seems a bit silly, so I wrote a RHEL (and CentOS) chkconfig compatible script to start it up and bring it down gracefully.
#!/bin/bash
#### linux chkconfig settings
# chkconfig: 345 01 99
# description: runs Xvfb on screen :2 at 1024x768x24
case $1 in
'start')
echo -n "Starting Xvfb..."
/usr/bin/Xvfb :2 -screen 0 1024x768x24 > /dev/null 2>&1 &
echo $! > /var/lock/subsys/Xvfb
RETVAL=$?
echo
[ $RETVAL = 0 ]
;
'stop')
echo -n "Stopping Xvfb..."
kill `cat /var/lock/subsys/Xvfb`
rm -f /var/lock/subsys/Xvfb
RETVAL=$?
echo
[ $RETVAL = 0 ]
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
update: I just found this wordpress plugin to make the script have proper tabs, and get syntax highlighting as a plus. Pretty slick.
Posted in Geek Stuff, Linux
Leave a Reply
search
recent comments
- Matt on Installing 32-bit Citrix Reciever on 64-bit Ubuntu
- Jay on Twitter Favorites for 04/26/10
- Dan Gilbert on I Know A Young Toddler
- Dan Gilbert on Don’t see the camera flashin’, Eats by sense of smell
- Chris Shattuck on Things I Would Like To Organize, But Am Unsure If Anyone Would Participate