CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   cfx5post in batch mode on "graphics-less" Linux (https://www.cfd-online.com/Forums/cfx/87015-cfx5post-batch-mode-graphics-less-linux.html)

frankyd April 8, 2011 17:48

cfx5post in batch mode on "graphics-less" Linux
 
I am getting the following error "cannot connect to X server" while running "cfx5post -batch xxx.cse" from command line. The OS is RHEL 4 and has no graphics card, and thereby the DISPLAY environment variable is not set. I have also tried "cfx5post -batch xxx.cse -graphics mesa" without success.

Does cfx5post need a graphics display while running in batch mode???


Frank D.

mjgraf April 10, 2011 21:16

unfortunately yes.
the way we got around this to run all our macros in batch mode was to create a virtual frame buffer.

Install xvfb
http://en.wikipedia.org/wiki/Xvfb
configure (even suggest to create an init.d script so it starts all the time).
Ensure you set a reasonable resolution and color depth.

then use the -display # switch for cfxpost.

If I recall, it stems from Qt and some quick of its system.

mjgraf April 12, 2011 11:26

Found my documentation
Detailed for Suse, but should be similar for RH.
Enjoy

Description
Xvfb is a virtual frame buffer to create an X display.

Installation

  1. Install Xvfb as part of YAST package: xorg-x11-server-extra
  2. Create the X auth file: /etc/Xvfb.auth
  3. Create the boot script: /etc/init.d/xvfb
  4. Make the new script executable: chmod +x /etc/init.d/xvfb
  5. Create symlink: ln -s /etc/init.d/xvfb /usr/sbin/rcxvfb
  6. Enable the init script: insserv /etc/init.d/xvfb
  7. Start the service: rcxvfb start
Notes

  • The X Auth file should only contain 'localhost'
  • One can dryrun insserv: insserv -n -v /etc/init.d/xvfb
  • insserv ensures that the new init scripts loads correctly
  • Check the init script for more info

Boot script

Xvfb script

Xvfb Settings
Display Number: 71
X Auth File: /etc/Xvfb.auth
Screen Setting: screen 0 2048x2048x24
Memory Mapped File: /tmp/Xvfb_screen0
Log File: /var/log/Xvfb_X71.log
Lock File: /tmp/.X71-lock

Code:

#!/bin/sh
#
#
# /etc/init.d/xvfb
#  and its symbolic link
# /usr/sbin/rcxvfb
#
### BEGIN INIT INFO
# Provides:          Xvfb
# Required-Start:    network nfs
# Should-Start:
# Required-Stop:    network
# Should-Stop:
# Default-Start:    3 5
# Default-Stop:
# Short-Description: Xvfb daemon, provides virtual frame buffer
# Description:      Start Xvfb
#    Primarily used for batch processing because
#    CFX and Ansys require an X Display.
### END INIT INFO
#

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
XVFB_BIN=/usr/bin/Xvfb
test -x $XVFB_BIN || { echo "$XVFB_BIN not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi; }

# Decided not to source a config file
# Left the code just incase
# Check for existence of needed config file and read it
#XVFB_CONFIG=/etc/sysconfig/xvfb
#test -r $XVFB_CONFIG || { echo "$XVFB_CONFIG not existing";
#    if [ "$1" = "stop" ]; then exit 0;
#    else exit 6; fi; }
#
# Read config
#. $XVFB_CONFIG

# The auth file is a plain text file with only "localhost" listed.
XVFB_DISPLAY=71
XVFB_AUTHFILE="/etc/Xvfb.auth"
test -r $XVFB_AUTHFILE || { echo "$XVFB_AUTHFILE not existing";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 7; fi; }
XVFB_SCREEN="-screen 0 2048x2048x24"
XVFB_MMAP="/tmp"
XVFB_LOG="/var/log/Xvfb_X$XVFB_DISPLAY.log"
XVFB_ARGS=":$XVFB_DISPLAY -auth $XVFB_AUTHFILE $XVFB_SCREEN -fbdir $XVFB_MMAP"


# Shell functions sourced from /etc/rc.status:
#      rc_check        check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v    be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s    display "skipped" and exit with status 3
#      rc_status -u    display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset        clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
    echo -n "Starting Xvfb on DISPLAY=:$XVFB_DISPLAY"
    # Remove the old log file
    rm -f $XVFB_LOG
    ## Start daemon with startproc(8). If this fails
    ## the return value is set appropriately by startproc.
    /sbin/startproc -l $XVFB_LOG $XVFB_BIN $XVFB_ARGS

    # Remember status and be verbose
    rc_status -v
    ;;
    stop)
    echo -n "Shutting down Xvfb "
    ## Stop daemon with killproc(8) and if this fails
    ## killproc sets the return value according to LSB.

    /sbin/killproc -TERM $XVFB_BIN

    # Remember status and be verbose
    rc_status -v
    ;;
    restart)
    ## Stop the service and regardless of whether it was
    ## running or not, start it again.
    $0 stop
    $0 start

    # Remember status and be quiet
    rc_status
    ;;
    status)
    echo -n "Checking for service Xvfb "
    ## Check status with checkproc(8), if process is running
    ## checkproc will return with exit status 0.

    # Return value is slightly different for the status command:
    # 0 - service up and running
    # 1 - service dead, but /var/run/  pid  file exists
    # 2 - service dead, but /var/lock/ lock file exists
    # 3 - service not running (unused)
    # 4 - service status unknown :-(
    # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)

    # NOTE: checkproc returns LSB compliant status values.
    /sbin/checkproc $XVFB_BIN
    # NOTE: rc_status knows that we called this init script with
    # "status" option and adapts its messages accordingly.
    rc_status -v
    ;;
    *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
rc_exit


frankyd April 12, 2011 16:47

Thanks mjgraf!

Using xvfb-run (wrapper around xvfb) solved the problem.

Frank D.


All times are GMT -4. The time now is 13:23.