Automating Tasks
From OpenSimulator
m (→Windows) |
(→Automate Grid Startup) |
||
Line 170: | Line 170: | ||
This depends on the screen NAME to be the same as in the startup script described above! | This depends on the screen NAME to be the same as in the startup script described above! | ||
--[[User:Suz|Suz]] 01:42, 18 May 2008 (PDT) | --[[User:Suz|Suz]] 01:42, 18 May 2008 (PDT) | ||
+ | |||
+ | ==Simulator Watchdog== | ||
+ | Watches the simulator process under Linux | ||
+ | |||
+ | Adding an entry to call a simple script to check the process table can restart regions that crash to the command line. Here [[User_talk:BlueWall]] is a script to accomplish this with a sample cron entry for one minute intervals. While it will not fix 100% of the crashes, it will get most cases, and help keep the grid healthy. If you have questions, you can usually find me on irc.freenode.net #opensim or #osgrid |
Revision as of 14:52, 19 June 2008
Contents |
Automate Grid Startup
Windows
Create a batch file to start up your grid, e.g. startGrid.bat ;
@Echo OFF For /F "Usebackq" %%i In (`Tasklist ^| Find /C "OpenSim"`) Do If /I %%i GTR 0 Echo There are %%i OpenSimulator processes running already. I quit! & Goto END :: %PROGRAMFILES% expands to your normal application path :: On an English system this is normally C:\Program Files :: If you run a 64-bit Windows, with OpenSim as a 32-bit :: application, substitute with %PROGRAMFILES(X86)% Echo Starting User Server... start "UserServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.UserServer.exe sleep 5 Echo Starting Grid Server... start "GridServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.GridServer.exe sleep 5 Echo Starting Asset Server... start "AssetServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.AssetServer.exe sleep 5 Echo Starting Inventory Server... start "InventoryServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.Grid.InventoryServer.exe sleep 5 Echo Starting Region Server... start "RegionServer" /MIN /D "%PROGRAMFILES%\OpenSim" OpenSim.exe -gridmode=true :END
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.*"
Or a more advanced batch that shut server processes down in the opposite order as recommended in the manual.
@Echo OFF For /F "Usebackq" %%i In (`Tasklist ^| Find /C "OpenSim"`) Do If /I %%i EQU 0 Echo There are no OpenSimulator processes running. Nothing to stop.. & Goto END Echo Stopping Region Server... taskkill /T /IM OpenSim.exe > NUL 2>&1 If ERRORLEVEL 128 Echo Region Server was not running! & Echo. & Goto n1 :r1 If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.exe > NUL 2>&1 If ERRORLEVEL 0 Echo Region Server stopped. & Echo. & Goto n1 Goto r1 :n1 Echo Stopping Inventory Server... taskkill /T /IM OpenSim.Grid.InventoryServer.exe > NUL 2>&1 If ERRORLEVEL 128 Echo Inventory Server was not running! & Echo. & Goto n2 :r2 If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.InventoryServer.exe > NUL 2>&1 If ERRORLEVEL 0 Echo Inventory Server stopped. & Echo. & Goto n2 Goto r2 :n2 Echo Stopping Asset Server... taskkill /T /IM OpenSim.Grid.AssetServer.exe > NUL 2>&1 If ERRORLEVEL 128 Echo Asset Server was not running! & Echo. & Goto n3 :r3 If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.AssetServer.exe > NUL 2>&1 If ERRORLEVEL 0 Echo Asset Server stopped. & Echo. & Goto n3 Goto r3 :n3 Echo Stopping Grid Server... taskkill /T /IM OpenSim.Grid.GridServer.exe > NUL 2>&1 If ERRORLEVEL 128 Echo Grid Server was not running! & Echo. & Goto n4 :r4 If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.GridServer.exe > NUL 2>&1 If ERRORLEVEL 0 Echo Grid Server stopped. & Echo. & Goto n4 Goto r4 :n4 Echo Stopping User Server... taskkill /T /IM OpenSim.Grid.UserServer.exe > NUL 2>&1 If ERRORLEVEL 128 Echo User Server was not running! & Echo. & Goto END :r5 If ERRORLEVEL 1 taskkill /T /F /IM OpenSim.Grid.UserServer.exe > NUL 2>&1 If ERRORLEVEL 0 Echo User Server stopped. & Echo. & Goto END Goto r5 :END
(Batch edits, Suz 04:46, 27 May 2008 (PDT))
Linux/Mac OS X
You can use this startup script
- 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
Or to shut down each session clean, make a stop script, stopgrid.sh
#!/bin/bash screen -S InventoryServer -X eval "stuff shutdown^M" sleep 5 screen -S AssetServer -X eval "stuff shutdown^M" sleep 5 screen -S GridServer -X eval "stuff shutdown^M" sleep 5 screen -S UserServer -X eval "stuff shutdown^M"
This depends on the screen NAME to be the same as in the startup script described above! --Suz 01:42, 18 May 2008 (PDT)
Simulator Watchdog
Watches the simulator process under Linux
Adding an entry to call a simple script to check the process table can restart regions that crash to the command line. Here User_talk:BlueWall is a script to accomplish this with a sample cron entry for one minute intervals. While it will not fix 100% of the crashes, it will get most cases, and help keep the grid healthy. If you have questions, you can usually find me on irc.freenode.net #opensim or #osgrid