Automating Tasks

From OpenSimulator

Revision as of 10:56, 16 March 2008 by Phrearch (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Automate Grid Startup

Windows

Create a file called StartGrid.BAT:

start OpenSim.Grid.UserServer.exe
sleep 3
start OpenSim.Grid.GridServer.exe
sleep 3
start OpenSim.Grid.AssetServer.exe
sleep 3
start OpenSim.Grid.InventoryServer.exe
sleep 3
start OpenSim.exe -gridmode=true

PS! Check that you have sleep command installed, I'm unsure if all Windows versions have that.
If sleep is not installed one can use a localhost ping instead to replace "sleep 3".

PING -n 4 127.0.0.1>nul

This knowledgebase article describes how to add a batch file to startup of Windows (before logon).
http://support.microsoft.com/kb/q243486/
Note that you have to start all applications and answer the configuration questions once before adding it to any startup.

If you start the server before logon then there will be no window to close if you want to shut down the server, so you can create a "StopGrid.BAT" with:

taskkill /FI "IMAGENAME eq OpenSim.*"
sleep 3
taskkill /FI "IMAGENAME eq OpenSim.*"
sleep 3
taskkill /F /FI "IMAGENAME eq OpenSim.*"

(Do they have to be shut down in any particular order?)

Linux/Mac OS X

  • Use Screen Command

Use the screen command to automate startup

  • Setup screen command and setup shell file

Linux install:

apt-get install screen (ubuntu)
pacman -S screen (archlinux)

Mac OS X: Download either MacPorts, http://www.macports.org/, or Fink, http://www.finkproject.org/ to download *nix packages MacPorts

sudo port install screen

Fink

Need command line for Fink.
  • Create file runsim.sh
#!/bin/sh
cd opensim/bin
sleep 3
screen -S UserServer -d -m  mono OpenSim.Grid.UserServer.exe
sleep 3
screen -S GridServer -d -m mono OpenSim.Grid.GridServer.exe
sleep 3
screen -S AssetServer -d -m mono OpenSim.Grid.AssetServer.exe
sleep 3
screen -S InventoryServer -d -m mono OpenSim.Grid.InventoryServer.exe
sleep 3
screen -S OpenSim -d -m mono OpenSim.exe -gridmode=true

Startup and access servers

./runsim.sh

If you have permission issues

chmod 755 runsim.sh

To see a list of the servers in screen:

screen -ls or screen -list

Output will look like the following:

There are screens on:
     8419.OpenSim  (Detached)
     8403.InventoryServer  (Detached)
     8378.AssetServer  (Detached)
     8360.GridServer  (Detached)
     8347.UserServer  (Detached)

To access server

screen -r 8419.OpenSim
screen -r 8403.InventoryServer
etc.

To exit screen, leaving server running, and to return to shell

ctrl-a d

Shutdown Servers

Either manually access each sceen

screen -r 8419.OpenSim
shutdown

Or use

killall mono

Or

for i in `ps afxu | grep -i "mono.*OpenSim" | grep -v grep | awk {'print $2'}`; do kill $i; done

Need to see if there is a way to use a shell script using screen to shutdown servers

Personal tools
General
About This Wiki