Smart Prestart WIN

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(quick housekeeping)
(page positioning changed - this page will be the subpage of Automating Tasks)
Line 1: Line 1:
 +
{{Template:Quicklinks}}
 +
 
'''Starting OpenSim with a little Pre-Processing'''  
 
'''Starting OpenSim with a little Pre-Processing'''  
  
Line 142: Line 144:
 
----
 
----
  
'''BACK-LINKS'''
+
Return to [[Automating Tasks]]
 
+
== Windows  ==
+
 
+
[[Smart Prestart WIN]] [[Backing Up WIN]] [[Automated Upgrade WIN]]
+
 
+
== Linux  ==
+
 
+
[[Smart Prestart LINUX]] [[Backing Up LINUX]] [[Automated Upgrade LINUX]]
+

Revision as of 20:31, 2 January 2011

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 Nov-24.2010
::
:: 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_(24-11-2010@23-27).log OR OSlog32_(24-11-2010@23-27).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\BACKups
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=PASSWORD
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 13-45 and colons are removed 
:: DATES are cleaned of / or - or : depending on your system install & config.
::
:: Parse Hour & Minutes Removing incorrect characters or leading spaces
:: i=HR, j=min, k=sec,l=msec
 for /F "usebackq tokens=1,2,3,4 delims=/-:. " %%i in ('%TIME%') do set Ttime=%%i-%%j
::
:: Parse the Date String removing unwated characters / 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
:: 
set TimeStamp=%Tdate%@%Ttime%
:: we now have a string which will appear as 24-11-2010@23-27
:: --------------------------------------------------------------------------------------
echo TimeStamp = %TimeStamp%
:: ==============================================
:: OPENSIM SYSTEM DATA BACKUP SECTION
:: ==============================================
:: 
:: if folders do not exist, create them for this OpenSim Instance
:: 
::
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% > %OSbackup%\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%"
::
::
::
:: ==============================================
:: 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

Return to Automating Tasks

Personal tools
General
About This Wiki