Automatic Start-up and Configuration

Normally, running a Chromium configuration involves starting the mothership then one or more server nodes (crserver) and application nodes (crappfaker). With the auto-start / auto-config feature you can simply run an OpenGL program normally and have it run on Chromium.

Auto-Start

The node.AutoStart() function allows you to execute an arbitrary shell command in order to spawn the Chromium crserver and crappfaker programs. This saves you from having to manually starting the programs yourself.

To start, let's define two strings with some environment variables and the name of the program to run:

env = "LD_LIBRARY_PATH=" + crlibdir
prog = crbindir + "/crserver"

Now, here's an example of how to autmatically start a crserver on a remote host named "mars" using rsh:

node.AutoStart( [ "/usr/bin/rsh", "mars",
                  "/bin/sh -c '" + env + " " + prog + "'" ] )

Here's an example of how to autmatically start a crserver on the local host just using sh:

node.AutoStart( ["/bin/sh", "-c", env + " " + prog] )

To start the crappfaker instead of crserver, just change the prog assignment above.

Basically, the AutoStart() function takes a list of command line arguments which are passed to the Python os.spawnv() function.

We use /bin/sh (the Bourne shell) to be sure that the environment variables will be interpreted correctly. You may have to do some tinkering to make things work correctly on your system. Some things to check:

Auto-Config

Auto-Config is a feature that automatically starts the mothership when you run an OpenGL program. In turn, the mothership can automatically start all the crappfaker and crserver processes (as described above). The end result is that users can run their OpenGL programs in the normal manner and automatically use Chromium.

This example assumes that Chromium is located in /usr/local/Chromium-x.y. Adjust these instructions accordingly if you have Chromium installed elsewhere.

The following steps need to be taken:

1. (For Unix/Linux) Use libcrfaker.so instead of libGL.so

We have to trick the OpenGL application into using the crfaker library instead of the normal OpenGL library. One solution is to create symbolic links from libcrfaker.so to libGL.so and libGL.so.1 and then use LD_LIBRARY_PATH to tell the application where to find the library. For example:

   cd /usr/local/Chromium-x.y/cr/lib/Linux
   ln -s libcrfaker.so libGL.so
   ln -s libcrfaker.so libGL.so.1
   setenv LD_LIBRARY_PATH /usr/local/Chromium-x.y/cr/lib/Linux

1. (For Microsoft Windows) Use libcrfaker.dll instead of opengl32.dll

We have to trick the OpenGL application into using the crfaker library instead of the normal OpenGL library. One solution is to copy the libcrfaker.dll to opengl32.dll and then use the PATH environment variable to tell the application where to find the library. This will ensure that the new opengl32.dll will be picked up before the system's version.

   cd c:\Chromium-x.y\cr\bin\WIN_NT
   copy libcrfaker.dll opengl32.dll
   set PATH=c:\Chromium-x.y\cr\bin\WIN_NT;....

2. Make a configuration file

A good way to make a configuration file is with the graphical configuration tool. You might make, for example, a tilesort configuration.

Make sure your configuration:

Save your configuration to a file such as /usr/local/Chromium-x.y/cr/mothership/configs/myconfig.conf

XXX -temporary

For the time being, you may have to edit your configuration file and specify the full path to the Chromium server's python directory:

   sys.path.append( "/usr/local/Chromium-x.y/cr/mothership/server" )

Otherwise, the configuration script may not be able to find the mothership.py file.

3. Set up the .crconfigs file

The .crconfigs file is expected to be in your home directory (i.e. at /home/joe/.crconfigs). If it's not found there, Chromium will look in the current directory when you start your application.

The .crconfigs file maps program names to configuration names. Each line of the file is of the format:

program configuration

Here's an example:

   atlantis  /usr/local/Chromium-x.y/cr/mothership/configs/myconfig.conf
   city      /usr/local/Chromium-x.y/cr/mothership/configs/tilecity.conf -r1 -c2
   *         /usr/local/Chromium-x.y/cr/mothership/configs/default.conf %p

This example specifies configuration files for the atlantis and city programs.

In the case of the city configuration, two optional command line arguments are given to the tilecity script to set the mural rows and columns.

The * (asterisk) entry denotes a default to use when there is no other match.

The %p sequence will be replaced by the program name. If %d is present, it will be replaced by the current working directory. if %m is present, it will be replaced by a a randomly chosen mothership port number. The spawned mothership will listen on that port.

4. The CR_CONFIG_PATH and CR_CONFIG environment variables

If the CR_CONFIG_PATH environment variable is set, it will provide an alternate file to look in for configuration. The file contents are identical to that in .crconfigs. It is merely an alternate way of specifying the location. Here's an example:

setenv CR_CONFIG_PATH "/tmp/autostart.conf"

If the CR_CONFIG environment variable is set, the .crconfigs file is not processed and no matching for program names is done. Instead, the contents of the CR_CONFIG variable are used instead to identify which mothership configuration file is to be used. The same syntax is used as for the configuration section of a line in the .crconfigs file. Here's an example:

setenv CR_CONFIG
"/usr/local/Chromium-x.y/cr/mothership/configs/tilecity.conf -r1 -c2"

Run it!

At this point running a program, such as city, should cause everything to start automatically. Here's what happens:

Trouble shooting

Here are some things to check if this doesn't work: