Jump to content
  • 0

Batch script to delete PBOs, repack PBOs from source, kill and re-launch server processes


mgm

Question

Hey guys

 

Finally went back and cleaned up my batch rebuild script. It's sitting at 100 actual lines and pretty basic.

Just to be clear this script is intended for people doing script development on the local host.

This is not for admins of 'normal' servers -- I know there is a better scheduled batch script somewhere in this forums (I think it's under Arma2Epoch sub-forum).

 

The script below does the following:

  1. Log the launch with a single line, to a log file.
  2. Delete existing server & client side PBOs.
  3. Repack server & client side PBOs from development sources.
  4. Kill arma3 dedicated server process in-between tasks 1 & 2, so that files won't be in use.
  5. Confirm redis database is running (if not, it will launch it).
  6. Finally launches arma3 dedicated server processes to enjoy the new PBOs.

I am sure most scripters already has something similar (possibly better) in place. I'm sharing this below as it might help complete beginners to get started quickly.

Would be good to improve if anybody has any suggestions...

 

Cheers

 

@ECHO OFF

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: BEGIN:	CONFIGURATION ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: SETTINGS AND PATHS 



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SERVERS, UTILITIES & LOGS
:: Command to launch the Arma3server
SET ARMA3SERVER_LAUNCH_COMMAND="D:\root\Arma_3_DS\z03_Launch_A3_Epoch.org_before_stratis.bat"

:: Command to launch redis server
SET REDISSERVER_LAUNCH_COMMAND="D:\root\Arma_3_DS\DB\start-redis.cmd"

:: Each run of this batch file is logged to the file configured below
SET	LOGFILEFULLPATH="D:\root\Arma_3_DS\mpmissions\DEV_DOCS\box___[store_most_frequestly_accessed_stuff_in_this_box]\script.01.del_repack_launch_server.log"

:: Application full path to pack directories in a PBO file
SET PBOCOMMAND="L:\Software\arma_stuff\cPBO_[PBO_pack_unpack_tool]\cpbo.exe"



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: SERVER SIDE CODE
:: Full path to SERVER-side code directory						(inside DEVELOPMENT_DIR)
SET CODE__SERVER_SIDE_FULLPATH="D:\root\Arma_3_DS\mpmissions\mgmTfA__DEVELOPMENT_DIR\server-side\mgmTfA"

:: Full path to save resulting SERVER-side code PBO file to			(under epochhive)
SET PBO_FULLPATH_FOR_SERVER_SIDE="D:\root\Arma_3_DS\@epochhive\addons\mgmTfA.pbo"

:: Full path resulting SERVER-side code PBO file extract directory		(under epochhive)		// in case you extract the PBO, check something in 'live PBO' and forget to delete it
SET PBODIR_FULLPATH_FOR_SERVER_SIDE="D:\root\Arma_3_DS\@epochhive\addons\mgmTfA\"



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: CLIENT SIDE CODE
:: Full path to CLIENT-side code directory 						(inside DEVELOPMENT_DIR)
SET CODE__CLIENT_SIDE_FULLPATH="D:\root\Arma_3_DS\mpmissions\mgmTfA__DEVELOPMENT_DIR\client-side\mgmTfA.Altis"

:: Full path to save resulting CLIENT-side code PBO file to			(under MPmissions)
SET PBO_FULLPATH_FOR_CLIENT_SIDE="D:\root\Arma_3_DS\mpmissions\mgmTfA.Altis.pbo"

:: Full path resulting SERVER-side code PBO file extract directory		(under epochhive)		// in case you extract the PBO, check something in 'live PBO' and forget to delete it
SET PBODIR_FULLPATH_FOR_CLIENT_SIDE="D:\root\Arma_3_DS\mpmissions\mgmTfA.Altis"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: END:	CONFIGURATION ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::




















:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: BEGIN:	MAIN WORKFLOW ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
GOTO SUB__LOG_THIS_RUN
	:CONTINUE_MAIN_WORKFLOW_FROM___LOG_THIS_RUN_FORK

GOTO SUB__KILL_IF_RUNNING__ARMA3SERVER
	:CONTINUE_MAIN_WORKFLOW_FROM___SUB__KILL_IF_RUNNING__ARMA3SERVER

GOTO SUB__DELETE_EXISTING_PBOS__REPACK_CODE_AS_PBO__COPY_PBOS_TO_PATHS
	:CONTINUE_MAIN_WORKFLOW_FROM___SUB__DELETE_EXISTING_PBOS__REPACK_CODE_AS_PBO__COPY_PBOS_TO_PATHS

GOTO SUB__REDIS_SERVER__CHECK_AND_RELAUNCH_IF_NECESSARY
	:CONTINUE_MAIN_WORKFLOW_FROM___SUB__REDIS_SERVER__CHECK_AND_RELAUNCH_IF_NECESSARY

:: Launch Arma3server with Epoch mod using the newly packed code
CALL %ARMA3SERVER_LAUNCH_COMMAND%

TIMEOUT 10

EXIT
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: END:	MAIN WORKFLOW ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::




















:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: BEGIN:	SUBROUTINE DEFINITIONS ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::: SUBROUTINE: BEGIN ::::::::::::::::::::
:SUB__LOG_THIS_RUN
ECHO script.01.del_repack_launch_server.bat executed at:		%DATE%  -  %TIME% >> %LOGFILEFULLPATH%
ECHO This execution logged to the log file.
::TIMEOUT 99
GOTO CONTINUE_MAIN_WORKFLOW_FROM___LOG_THIS_RUN_FORK
:::::::::::::::::::: SUBROUTINE: END ::::::::::::::::::::



:::::::::::::::::::: SUBROUTINE: BEGIN ::::::::::::::::::::
:SUB__REDIS_SERVER__CHECK_AND_RELAUNCH_IF_NECESSARY
TASKLIST /FI "IMAGENAME eq redis-server.exe" 2>NUL | FIND /I /N "redis-server.exe">NUL
IF "%ERRORLEVEL%"=="0" (
	:: KILL code here
	ECHO REDIS SERVER RUNNING. No action necessary at this time.
) ELSE (
	ECHO LAUNCHING REDIS SERVER as it was not running.
	CALL %REDISSERVER_LAUNCH_COMMAND%
)
:: we are done here. return to the caller
GOTO CONTINUE_MAIN_WORKFLOW_FROM___SUB__REDIS_SERVER__CHECK_AND_RELAUNCH_IF_NECESSARY
:::::::::::::::::::: SUBROUTINE: END ::::::::::::::::::::



:::::::::::::::::::: SUBROUTINE: BEGIN ::::::::::::::::::::
:SUB__KILL_IF_RUNNING__ARMA3SERVER
TASKLIST /FI "IMAGENAME eq arma3server.exe" 2>NUL | FIND /I /N "arma3server.exe">NUL
IF "%ERRORLEVEL%"=="0" (
	:: KILL code here
	ECHO arma3server found to be running. KILLING it now...
	:: kill all instances of arma3server.exe
	TASKKILL /F /IM arma3server.exe
	:: Wait a second to allow kill to come in effect
	TIMEOUT 1
	:: Wait for file locks in the background to be released (as rePBO process will need to overwrite these)
	TIMEOUT 4
) ELSE (
	ECHO ARMA3 server NOT RUNNING. No action necessary at this time.
)
:: we are done here. return to the caller
GOTO CONTINUE_MAIN_WORKFLOW_FROM___SUB__KILL_IF_RUNNING__ARMA3SERVER
:::::::::::::::::::: SUBROUTINE: END ::::::::::::::::::::



:::::::::::::::::::: SUBROUTINE: BEGIN ::::::::::::::::::::
:SUB__DELETE_EXISTING_PBOS__REPACK_CODE_AS_PBO__COPY_PBOS_TO_PATHS

:::::::::::::::::::: If it exists:		DELETE the unpacked "Epoch Autostart Addon" directory for the mod 
IF EXIST %PBODIR_FULLPATH_FOR_SERVER_SIDE% (
	ECHO The directory %PBODIR_FULLPATH_FOR_SERVER_SIDE% exists -- I will delete it now.
	rmdir %PBODIR_FULLPATH_FOR_SERVER_SIDE% /s /q
) ELSE (
	ECHO The directory %PBODIR_FULLPATH_FOR_SERVER_SIDE% does not exist -- nothing to be do at this time.
)
::TIMEOUT 99
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



:::::::::::::::::::: If it exists:		DELETE the unpacked "Epoch MPmission" directory for the mod 
IF EXIST %PBODIR_FULLPATH_FOR_CLIENT_SIDE% (
	ECHO The directory %PBODIR_FULLPATH_FOR_CLIENT_SIDE% exists -- I will delete it now.
	rmdir %PBODIR_FULLPATH_FOR_CLIENT_SIDE% /s /q
) ELSE (
	ECHO The directory %PBODIR_FULLPATH_FOR_CLIENT_SIDE% does not exist -- nothing to be do at this time.
)
::TIMEOUT 99
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



:::::::::::::::::::: If it exists:		DELETE the packed "Epoch Autostart Addon" file the mod 
IF EXIST %PBODIR_FULLPATH_FOR_SERVER_SIDE% (
	ECHO The file %PBODIR_FULLPATH_FOR_SERVER_SIDE% does exist -- I will  delete it now.
	DEL %PBODIR_FULLPATH_FOR_SERVER_SIDE%
) ELSE (
	ECHO The file %PBODIR_FULLPATH_FOR_SERVER_SIDE% does not exist -- nothing to be do at this time.
)
::TIMEOUT 99
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



::::::::::::::::::::BEGIN:	If it exists:		DELETE the packed "Epoch MPmissions client-side mission" file of the mod
IF EXIST %PBO_FULLPATH_FOR_CLIENT_SIDE% (
	ECHO The file %PBO_FULLPATH_FOR_CLIENT_SIDE% does exist -- I will  delete it now.
	DEL %PBO_FULLPATH_FOR_CLIENT_SIDE%
) ELSE (
	ECHO The file %PBO_FULLPATH_FOR_CLIENT_SIDE% does not exist -- nothing to be do at this time.
)
::TIMEOUT 99
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



:::::::::::::::::::: Repack the SERVER code in DEVELOPMENT_DIR 			and place the resulting PBO file under Epoch's @epochhive\addons directory
::cd /D "L:\Software\arma_stuff\cPBO_[PBO_pack_unpack_tool]"
%PBOCOMMAND%	-y -p %CODE__SERVER_SIDE_FULLPATH%			%PBO_FULLPATH_FOR_SERVER_SIDE%
ECHO Server-side file packed as:				%PBO_FULLPATH_FOR_SERVER_SIDE%
::TIMEOUT 99
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



:::::::::::::::::::: Repack the CLIENT code in DEVELOPMENT_DIR 			and place the resulting PBO file under Epoch's MPmissions directory
%PBOCOMMAND%	-y -p %CODE__CLIENT_SIDE_FULLPATH%		%PBO_FULLPATH_FOR_CLIENT_SIDE%
ECHO Client-side MPmission file packed as:			%PBO_FULLPATH_FOR_CLIENT_SIDE%
::TIMEOUT 99
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: we are done here. return to the caller
GOTO CONTINUE_MAIN_WORKFLOW_FROM___SUB__DELETE_EXISTING_PBOS__REPACK_CODE_AS_PBO__COPY_PBOS_TO_PATHS
:::::::::::::::::::: SUBROUTINE: END ::::::::::::::::::::



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: END:	SUBROUTINE DEFINITIONS ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: EOF

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I have now added a basic statistics collection, using cygwin environment.

Each time batch file is executed on top of generating a new build (as per original 1st post above) script now also generates stats similar to what you see below.

 

Stats are generated and logged in human-friendly & machine-friendly formats. human-friendly format is also displayed on screen for a quick overview (timesout and auto closes after a threshold seconds - I use 15 seconds).

 

 

human-friendly output:                         <== to be   used   for quick on-screen check (also logged to separate file)
CURRENT_TIMESTAMP_STRING    : 20150409_2314.12
CURRENT_EPOCH_TIMESTAMP    : 1428617651
LINES_ALL_TOTAL            : 11603
LINES_ALL_EXCEPT_COMMENTS    : 7840
LINES_COMMENTS            : 3763
LINES_ALL_EXCEPT_COMMENTS_AND_BLANKS___THIS_IS_ACTUAL_CODE_DOES_NOT_EXCLUDE_TOBEEXCLUDED_FILES: 6137
LINES_IN_TOBEEXCLUDED_FILES: 1210
LINES_FINAL_ACTUAL_CODE    : 4927
CODE_COMMENT_RATIO        : 76

 

machine-friendly output:                         <== to be used for gnuplot image generation

1428617651 11603 7840 3763 6137 1210 4927 76                

 

Obviously requires some work but this is version 0.1 :)

Stats collection is working as per above and I will share this after completing my work on the initial public alpha release of Transport for Arma

 

 

Another function I've added is writing these data to a local log file in machine-friendly format.

 

 

Once TfA initial release is done I will revisit this and the above machine-friendly data will be used to execute gnuplot to generate images from stats - output should look like the below examples.

I will have to decide what exactly to plot and how to present it to make it immediately meaningful (and hopefully handsome).

 

Example Image 1

showcase_plot.1.png

 

 

Example Image 2

weekly_boxes.png

 

 

 

 

Example Image 3

YPS4d.png

 

 

 

Example Image 4

IPBhq.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...