Integrate MongoDB into C2R

Signed-off-by: Jaida Wu <mlgmxyysd@meowcat.org>
This commit is contained in:
Jaida Wu 2022-04-22 11:33:54 +08:00
parent c157aaec5b
commit 1133ffd9aa
No known key found for this signature in database
GPG Key ID: 2A5EF9CA5CD6B350

View File

@ -11,11 +11,12 @@ call :LOG [INFO] To proper exit this console, use [Ctrl + C] and enter N not Y.
call :LOG [INFO] call :LOG [INFO]
call :LOG [INFO] Initializing... call :LOG [INFO] Initializing...
@rem TODO: MongoDB integration
set JAVA_PATH=DO_NOT_CHECK_PATH set JAVA_PATH=DO_NOT_CHECK_PATH
set MITMDUMP_PATH=DO_NOT_CHECK_PATH set MITMDUMP_PATH=DO_NOT_CHECK_PATH
set MONGODB_PATH=DO_NOT_CHECK_PATH
set SERVER_JAR_PATH=%CUR_PATH% set SERVER_JAR_PATH=%CUR_PATH%
set DATABASE_STORAGE_PATH=%CUR_PATH%resources\Database
set SERVER_JAR_NAME=grasscutter.jar set SERVER_JAR_NAME=grasscutter.jar
set PROXY_SCRIPT_NAME=proxy set PROXY_SCRIPT_NAME=proxy
@ -98,11 +99,35 @@ reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v Pr
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "127.0.0.1:8080" /f >nul 2>nul reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "127.0.0.1:8080" /f >nul 2>nul
:SERVER :SERVER
if not "%MONGODB_PATH%" == "DO_NOT_CHECK_PATH" (
if not exist "%MONGODB_PATH%mongod.exe" (
call :LOG [WARN] MongoDB daemon not found, server only mode.
goto :GAME
)
) else set MONGODB_PATH=
call :LOG [INFO] Starting MongoDB daemon...
set DATABASE=true
mkdir "%DATABASE_STORAGE_PATH%" >nul 2>nul
echo set ws = createobject("wscript.shell") > "%temp%\db.vbs"
echo ws.currentdirectory = "%MONGODB_PATH%" >> "%temp%\db.vbs"
echo ws.run "cmd /c mongod.exe --dbpath "^&chr(34)^&"%DATABASE_STORAGE_PATH%"^&chr(34)^&"",0 >> "%temp%\db.vbs"
"%temp%\db.vbs"
del /f /q "%temp%\db.vbs" >nul 2>nul
:GAME
call :LOG [INFO] Starting server... call :LOG [INFO] Starting server...
"%JAVA_PATH%java.exe" -jar "%SERVER_PATH%grasscutter.jar" "%JAVA_PATH%java.exe" -jar "%SERVER_PATH%grasscutter.jar"
call :LOG [INFO] Server stopped call :LOG [INFO] Server stopped
:EXIT :EXIT
if "%DATABASE%" == "" (
call :LOG [INFO] MongoDB daemon not started, no need to clean up.
) else (
call :LOG [INFO] Shutting down MongoDB daemon...
taskkill /t /f /im mongod.exe >nul 2>nul
)
if "%PROXY%" == "" ( if "%PROXY%" == "" (
call :LOG [INFO] Proxy daemon not started, no need to clean up. call :LOG [INFO] Proxy daemon not started, no need to clean up.
) else ( ) else (