Smart Prestart WIN

From OpenSimulator

Revision as of 15:22, 15 September 2009 by WhiteStar (Talk | contribs)

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

Starting OpenSim with a little Pre-Processing

I created this Batch File to run a couple of things for me on startup and thought it would be good to share the base of it for others to be able to further better manage their systems. I like to review my OpenSim.Log when I do a Startup and as you know, that thing becomes a Monster very fast ! BTW: It's also not good to open the "Live Log" when the system is running because it can cause the console to lockup (hate file locking @ times).


  • What this does is described in the batch file, in a nutshell:

Presets a TimeStamp for Date@HourMinute

  • Copies \bin\opensim.log or \bin\opensim.32bitLaunch.log to the backup folder structure as defined.
  • The DEFAULT is C:\OpenSim\InstanceA\BACKups\LOGS
  • Next, it renames the copied opensim.log to OSLOG_(14052009@1100).log so now it is Date@HourMinute stamped in the filename.
  • Next, it clears the \bin\opensim.log and inserts "LOG_CLEARED AT 14052009@1100" as the first line in the file.
  • WHY? Easier to track startup issues / debugging and helps reduce size of live opensim.log
  • Creates backup structure under the instance to store critical files for recovery & tracking
  • Copies critical files into backup structure (*.db, *.ini, exports, regions files ini or xml)
  • OPTIONALLY BACKS UP MYSQL DB
  • Changes directory to the \BIN folder and starts OpenSim.exe


INSTALLATION:

  • Startup with a shortcut as you would with standard opensim.exe, just start this batch file instead instead of opensim.exe
  • !! Remember to set the 5 Important Variables for your paths at the top of the batch file as shown below:
  • OPTIONALLY Now Also dumps MySql DataBase SEE Header in batchfile

SET OSbackup=C:\OpenSim\InstanceA\BACKups
SET OSbinSrc=C:\OpenSim\InstanceA\bin
set DBUSER=root
set DBPW=YOURPASSWORD
set DBNAME=opensim


That's it... Nice & Easy, always a clean log when you startup and a copy of the previous log stored for you to review

THE BATCHFILE Start_OS.BAT


@echo off
:: FILENAME: Start_OS.BAT
:: AUTHOR: WhiteStar Magic @ OSGrid
:: DATE: REVISED SEP-15-2009
::
:: DESCRIPTION: Starts OpenSim.exe with some preprocessing
:: - copies opensim.log from BIN\ folder to Log Backup & renames it to OSLOG_Date@time.log
:: - example of output OSlog_(14052009@1019).log OR OSlog32_(14052009@1019).log
:: - then it CLEARS the log to EMPTY in the \BIN folder so you can see everything from startup
:: - WHY? Easier to track startup issues / debugging and helps reduce size of live opensim.log
:: - Creates backup structure under the instance to store critical files for recovery & tracking
:: - Copies critical files into backup structure
:: - BACKS UP MYSQL DB
::
:: INSTALLATION:
:: Startup with a shortcut as you would with standard opensim.exe, just start this batch file instead
:: MODIFY the bottom lines to adjust for starting OpenSim.exe OR OpenSim.32BitLaunch.exe
::
:: DEPENDENCIES: uses Robocopy.exe (Windows Application) free from Microsoft if not in your installation
:: SYSTEM IMPACT: None Known
:: TESTED ON: Windows Vista, Windows-7RC, WINDOWS SERVER 2008-R1(64bit)
:: Other Windows Operating Systems should have no issue (untested) but they are consistent for this type of function
:: =================================================================================================================
:: CONFIGURING ENVIRONMENT PATHS AND SETUP TO SIMPLIFY CONFIG & ADMIN
:: Adjust the following to YOUR INSTALLED Folder Paths
::
:: OSbackup = Where you want your Backup File Structure to be and send files to
:: OSbinSrc = Where the OpenSim Software is installed and run from
::
SET OSbackup=C:\OpenSim\INSTANCEa\BACKup
SET OSbinSrc=C:\OpenSim\INSTANCEa\bin
::
:: MYSQL INFORMATION TO BE FILLED OUT.
:: IF DBUSER=XXX MySql Dump will not occur
set DBUSER=root
set DBPW=YOURPASSWORD
set DBNAME=opensim
::
:: --------------------------------------------------------------------------------------
:: DATE & TIME String Assembly
:: --------------------------------------------------------------------------------------
:: Date & Time Format on your system
:: Check your format in command.prompt with DATE/T
::
:: EU DATE FORMAT = 15-05-2006 DD-MM-YYYY
:: US DATE FORMAT = 05/17/2006 MM/DD/YYYY
:: TIME FORMAT 13:45:55 is truncated to 1345 and colons are ::oved
:: DATES are cleaned of / or - or : depending on your system install & config.
::
:: Parse Hour & Minutes Removing : or leading spaces
for /F "usebackq tokens=1 delims=:" %%i in ('%TIME%') do set HRa=%%i
:: fix the HR in case it has a blank in it
for /F "usebackq tokens=1 delims= " %%i in ('%HRa%') do set HR=%%i
for /F "usebackq tokens=2 delims=:" %%i in ('%TIME%') do set MIN=%%i
::
:: Parse the Date String ::oving unwated charachters / or - or 'space' depends on system installation
for /F "usebackq tokens=1,2,3,4 delims=/- " %%i in ('%DATE%') do set Tdate=%%i%%j%%k%%l
::
set TimeStamp=%Tdate%@%HR%%MIN%
:: we now have a string which will appear as 12052009@0112
:: --------------------------------------------------------------------------------------
echo TimeStamp = %TimeStamp%
:: ==============================================
:: OPENSIM SYSTEM DATA BACKUP SECTION
:: ==============================================
::
:: if folders do not exist, create them for this OpenSim Instance
::
@echo OFF
::
if not exist %OSbackup%\*.* md %OSbackup%
if not exist %OSbackup%\DB\*.* md %OSbackup%\DB
if not exist %OSbackup%\DBsql\*.* md %OSbackup%\DBsql
if not exist %OSbackup%\EXPORTS\*.* md %OSbackup%\EXPORTS
if not exist %OSbackup%\INI\*.* md %OSbackup%\INI
if not exist %OSbackup%\LOGS\*.* md %OSbackup%\LOGS
if not exist %OSbackup%\OAR\*.* md %OSbackup%\OAR
if not exist %OSbackup%\REGIONS\*.* md %OSbackup%\REGIONS
if not exist %OSbackup%\TERRAINS\*.* md %OSbackup%\TERRAINS
if not exist %OSbackup%\TXT\*.* md %OSbackup%\TXT
if not exist %OSbackup%\XML2\*.* md %OSbackup%\XML2
:: !! Copy Critical Files !!
robocopy %OSbinSrc% %OSbackup%\DB *.DB /S /LOG:%OSbackup%\DBlog.txt
robocopy %OSbinSrc%\Exports %OSbackup%\EXPORTS *.* /S /LOG:%OSbackup%\EXPORTSlog.txt
robocopy %OSbinSrc% %OSbackup%\INI *.ini /S /LOG:%OSbackup%\INIlog.txt
robocopy %OSbinSrc%\Regions %OSbackup%\REGIONS *.* /S /LOG:%OSbackup%\REGIONSlog.txt
robocopy %OSbinSrc% %OSbackup%\TXT *.txt /S /LOG:%OSbackup%\TXTlog.txt
::
:: generate MySql DB Backup
if DBUSER NEQ XXX mysqldump --opt -u%DBUSER% -p%DBPW% %DBNAME% > %OS_Instance%\BACKup\DBsql\%DBNAME%.sql
::
if exist %OSbinSrc%\OpenSim.32BitLaunch.log copy %OSbinSrc%\OpenSim.32BitLaunch.log %OSbackup%\LOGS\OSlog32_(%TimeStamp%).log
if exist %OSbinSrc%\OpenSim.log copy %OSbinSrc%\OpenSim.log %OSbackup%\LOGS\OSlog_(%TimeStamp%).log
if exist %OSbinSrc%\XEngine.log copy %OSbinSrc%\XEngine.log %OSbackup%\LOGS\XEngine_(%TimeStamp%).log
::
:: NEXT FLUSHING LOG to EMPTY
if exist %OSbinSrc%\OpenSim.32BitLaunch.log >%OSbinSrc%\OpenSim.32BitLaunch.log echo "LOG_CLEARED AT %TimeStamp%"
if exist %OSbinSrc%\OpenSim.log >%OSbinSrc%\OpenSim.log echo "LOG_CLEARED AT %TimeStamp%"
if exist %OSbinSrc%\xengine.log >%OSbinSrc%\xengine.log echo "LOG_CLEARED AT %TimeStamp%"
::
@echo OFF
::
::
:: ==============================================
:: STARTING OPENSIM SERVER
:: ==============================================
:: change directory to \bin to make sure and startup system as usual
:: uncomment according to Operating System. OpenSim.exe = 32bit OS, OpenSim.32BitLaunch.exe = 64bit operating system
::
cd %OSbinSrc%
:: OpenSim.32BitLaunch.exe
OpenSim.exe
Personal tools
General
About This Wiki