User:Allen Kerensky/Environment Variables

From OpenSimulator

Jump to: navigation, search

Environment Variables

Archived here from [Test Page] to prevent disappearance.

MONO_THREADS_PER_CPU

By default, OpenSimulator only recognizes one shell environment variable: MONO_THREADS_PER_CPU

If this variable is set in your shell before starting OpenSimulator, it will allow you to control the number of threads Mono will host per CPU.

The proper setting for this variable somewhat subject to religious interpretation.

Common recommendations including bumping it up to around 100 on many OpenSim installations.

Others have recommended numbers as high as 2048.

This article on Threadpool Deadlocks may help.

Using shell environment variables in OpenSim configuration

We will need to use two new things in our configurations: a section [Environment] to tell us what variables we need to look at in the shell and we will need to use the Nini key expansion. Nini, can have keys that look like ${SECTION|VARIABLE} and can expand those to the variables we assign.

In your shell you will export your values and check the ones you want to use that are predefined by your system ...

export RT_ZONE=Zone_00
# You can see your HOSTNAME (It will be set by the system)...
echo $HOSTNAME
OSERV_00

In the ini you will include an [Environment] section...

[Environment]  ; Our Environment section that defines the shell variables we are interested in
RT_ZONE=""     ; We might use a zone to setup an instance of OpenSim on a server  
HOSTNAME="" ; We might be interested in obtaining the host's name 
 
[Startup]
regionload_regionsdir=/home/opensim/etc/Regions/${Environment|RT_ZONE}/   ; We set our regionload_regionsdir using the variables
ConsolePrompt = "${Environment|HOSTNAME}:${Environment|RT_ZONE} "
 
[DatabaseService]
ConnectionString = "Data Source=localhost;Database=${Environment|RT_ZONE};User ID=username;Password=userpass;" ; Here too

When OpenSim picks up the variables in your shell and processes all the configurations, the variable keys will be filled in with the variables picked up from the shell ...

[Environment]  ; Our Environment section that defines the shell variables we are interested in
RT_ZONE=""     ; We might use a zone to setup an instance of OpenSim on a server  
HOSTNAME="" ; We might be interested in obtaining the host's name 
 
[Startup]
regionload_regionsdir=/home/opensim/etc/Regions/Zone_00/   ; We set our regionload_regionsdir using the variables
ConsolePrompt = "OSERV_00:Zone_09 "
 
[DatabaseService]
ConnectionString = "Data Source=localhost;Database=Zone_00;User ID=username;Password=userpass;" ; Here too

This is a pretty good start. I think there will be a couple of places we might be able to use this to help us setup really flexible configuration systems for OpenSim.

Have Fun!

Personal tools
General
About This Wiki