[idvusers] Running the IDV in background on a headless server with isl control (IDV 2.6u2, Linux, Xvfb, isl file)

  • To: idvusers@xxxxxxxxxxxxxxxx
  • Subject: [idvusers] Running the IDV in background on a headless server with isl control (IDV 2.6u2, Linux, Xvfb, isl file)
  • From: Stuart Wier <wier@xxxxxxxxxx>
  • Date: Tue, 05 Jan 2010 09:36:33 -0700

Running the IDV in background on a headless server with isl control, to make 
displays for a web page.

This can be used also as a guide for other, non web, background IDV calls.

Here are details of one working Linux/Redhat set up, as it is so far. I am also working on a Sun server but with no success yet.

The web page and interface is some php file such as idvpage.php, with code including tyoically HTML, PHP, and Javascript. It provides the online user interface for the user to choose a data source, a display type, and other choices, and shows the display image file in the web page after the new display image is made.

System used for development

cat /etc/redhat-release
CentOS release 4.4 (Final)

uname -a
Linux geon.unavco.org 2.6.9-42.0.2.ELsmp #1 SMP Wed Aug 23 00:17:26 CDT 2006 
i686 i686 i386 GNU/Linux

The processes run by the web interface are under user apache. User apache has 
no login nor a shell:
cat /etc/passwd | grep apache
apache:x:48:48:Apache:/var/www:/sbin/nologin


Installing the GEON IDV

See http://geon.unavco.org/unavco/IDV_for_GEON_download.html.
Use version 2.6u2 of the IDV; have not yet gotten newer versions to work.
Installing the IDV involves running it with a graphics display, so you will 
need to log in remotely with ssh -X username.
The installation process runs the IDV, so you will see that it works ok, or at 
least starts.


XWindows support

Run the Xwindows

My glxinfo returns
name of display: localhost:10.0
display: localhost:10  screen: 0
direct rendering: Yes
server glx vendor string: Brian Paul
server glx version string: 1.4 Mesa 7.5.2
server glx extensions:
    GLX_MESA_copy_sub_buffer, GLX_MESA_pixmap_colormap,
    GLX_MESA_release_buffers, GLX_ARB_get_proc_address,
    GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating,
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer
client glx vendor string: Brian Paul
client glx version string: 1.4 Mesa 7.5.2
client glx extensions:
    GLX_MESA_copy_sub_buffer, GLX_MESA_pixmap_colormap,
    GLX_MESA_release_buffers, GLX_ARB_get_proc_address,
    GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating,
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer
GLX extensions:
    GLX_MESA_copy_sub_buffer, GLX_MESA_pixmap_colormap,
    GLX_MESA_release_buffers, GLX_ARB_get_proc_address,
    GLX_EXT_texture_from_pixmap, GLX_EXT_visual_info, GLX_EXT_visual_rating,
    GLX_SGIX_fbconfig, GLX_SGIX_pbuffer
OpenGL vendor string: Brian Paul
OpenGL renderer string: Mesa X11
OpenGL version string: 2.1 Mesa 7.5.2
OpenGL extensions:
    GL_ARB_depth_texture, GL_ARB_draw_buffers, GL_ARB_fragment_program,
    GL_ARB_fragment_program_shadow, GL_ARB_fragment_shader,
...


Xvfb

Even in background the IDV still needs to be run with an active window system 
(e.g., X, MS Windows) for it to work.
On Linux you need to run the IDV with the X virtual frame buffer, Xvfb.

Download Xvfb.tgz from 
ftp://ftp.xfree86.org/pub/XFree86/4.8.0/binaries/Linux-ix86-glibc22/ and unpack 
it.
I am using the most recent version of Xvfb, 4.8.0.  At least one older version 
of Xvfb does not work with IDV 2.6u2.

My Xvfb file that works has size and date
3918055 Jan 12  2009 Xvfb

As user root or apache run this
./xvfb4.8.0/bin/Xvfb :9 -screen 0 1280x1280x24 &

This sets the screen number to 0 and the display number to the arbitrary :9. Note that a small screen size like 1x1x24 causes the IDV to fail with errors. You may need root permission to start this as apache, or you can add it to the very first run of the script runidv2 described below. Note that Xvfb must be running for the IDV to make images. The IDV images must be smaller than 1280x1280 pixels; larger sizes may be possible by changing the Xvfb args.

The running process looks like, for example, with ps aux | grep vfb
apache   23658  0.1 21.4 1015432 444524 ?    S    Dec10  10:02 
/.../xvfb4.8.0/bin/Xvfb :9 -screen 0 1280x1024x24

About Xvfb, See http://www.xfree86.org/4.0.1/Xvfb.1.html, a man page.

Note that I was only able to get the IDV to make displays on this system with 
IDV 2.6u2 and Xvfb 4.8.0.


Calling the IDV

Scripts runidv1 and rundiv2 are static files which allow the processes to execute and also allow output or error messages to be caught. Set privileges so they cannot be deleted or overwritten.

runidv1 has one line:

./idv_config_files/runidv2   >&  logs/runidv1_log

So runidv1 calls runidv2, with output log file.

runidv2 contains this (or something like it):

DISPLAY=:9
# note this must match the display number in the Xvfb command line.
export DISPLAY
#echo "   xwindow display number is  "
#echo $DISPLAY

#     kill running apache owned xvfb process
#     in rare instance you want to restart it
# kill -9 22883

#   Start Xvfb with root, or here, or  as user apache, i.e. sudo -u apache
#echo "   start Xvfb  "
#/home/xvfb/xvfb4.8.0/bin/Xvfb :9 -screen 0 1280x1024x24
# echo "   show Xvfb process:  "
# ps aux | grep vfb

echo "   start IDV  "
date
# run the IDV under isl control:
/home/idv/IDV_2.6u2/jre/bin/java -Xmx1200m -jar /home/idv/IDV_2.6u2/idv.jar -userpath /home/idv/DefaultIdv -Didv.enableStereo=false /home/idv/idv_config_files/working.isl >& /home/idv/docs/idv_isl_run_log
echo "   done "
date
# end runidv2

runidv2 is static in operations but may be changed during development to run 
Xvfb (once), etc.

Note that file permissions must be set so that apache can run or write to files.

One might simplify this runidv1 and runidv2 method but it allows the developer 
to watch what is happening.


ISL file

The GEON IDV uses “isl” (IDV scripting language) files to make an image while running in background. For details about isl scripts, see http://www.unidata.ucar.edu/software/IDV/docs/userguide/isl/index.html.

A sample isl file used in this case is
<?xml version="1.0" encoding="ISO-8859-1"?>
<isl debug="true" loop="1" offscreen="true" sleep="60.0minutes">
  <bundle clear="true" file="/home/idv/configs/working.xidv" wait="true"/>
  <image 
file="/home/idv/displays/isosurface_view2_value-0.5_datetime20100105085837.png"/>
</isl>

The isl file is made from a generic isl file by the php code inserting the 
particular image file name.


XIDV file

The file working.xidv is a normal IDV xidv file with all the specifications to 
display some named data in a certain way.
The xidv file is made from a generic xidv file by the php code inserting the particular data source file name and other parameters.
For example, part of a working xidv file is, where the data file name 
MITP_USA_2008DEC.nc has been inserted:
               <object class="ucar.unidata.data.grid.GeoGridDataSource" 
id="id12">
                    <property name="Sources">
                        <object class="java.util.ArrayList">
                            <method name="add">
                                
<string><![CDATA[/state/unavco/idvserver/datasets/MITP_USA_2008DEC.nc]]></string>
                            </method>
                        </object>
                    </property>

The Run Sequence

On user “Submit request” the idvpage.php gets the user's choices with the usual HTML form-POST technique. idvpage.php code then creates the files working.ils and working.xidv needed for this particular request. The idvpage.php code also creates a new unique name for the image file that will be made.

idvpage.php does the PHP “system” execute command for runidv1.  rundiv1 calls 
runidv2

runidv2 runs the IDV with the command line above, using the isl file.

The IDV starts and reads the “isl” file idv_config_files/working.isl which among other things tells the IDV to run in background.

The IDV creates the image file. When the IDV completes, the idvpage.php resumes, redraws the screen, now showing the image file since the php code knows the path and name of the new image file.

Making one 1200 pixel image takes from 20 to 60 seconds on this system 
depending on how complex the display is.



  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the idvusers archives: