mirror of
https://github.com/SillyTavern/SillyTavern-Launcher.git
synced 2026-04-30 19:21:22 +00:00
Modularization/Organization - Find App Title for Port
Added some basic modularization and reorganization. - Moved logs to /bin/logs - Moved create_ssl.bat, fetch_title.js and log_wrapper.bat to /bin/functions/~/ Add functionality to troubleshooting port finder to find the Title of the the application using the port
This commit is contained in:
@@ -18,7 +18,7 @@ if "%silentMode%"=="true" (
|
||||
)
|
||||
|
||||
:: Set the SSL certificate directory and files
|
||||
set "SILLYTAVERN_DIR=%~dp0..\SillyTavern"
|
||||
set "SILLYTAVERN_DIR=%~dp0..\..\..\SillyTavern"
|
||||
set "CERT_DIR=%SILLYTAVERN_DIR%\certs"
|
||||
set "CERT_FILE=%CERT_DIR%\cert.pem"
|
||||
set "KEY_FILE=%CERT_DIR%\privkey.pem"
|
||||
@@ -90,12 +90,8 @@ for /f %%i in ('powershell -command "[datetime]::Now.AddDays(825).ToString('MM/d
|
||||
)
|
||||
|
||||
:: Store the certificate and key path, and expiration date in the text file
|
||||
:: Correcting the paths to remove the "bin\.."
|
||||
set "correctCertPath=%SILLYTAVERN_DIR:\..\SillyTavern=\\SillyTavern%\certs\cert.pem"
|
||||
set "correctKeyPath=%SILLYTAVERN_DIR:\..\SillyTavern=\\SillyTavern%\certs\privkey.pem"
|
||||
|
||||
echo %correctCertPath% > "%CERT_INFO_FILE%"
|
||||
echo %correctKeyPath% >> "%CERT_INFO_FILE%"
|
||||
echo %CERT_FILE% > "%CERT_INFO_FILE%"
|
||||
echo %KEY_FILE% >> "%CERT_INFO_FILE%"
|
||||
echo SSL Expiration Date (mm/dd/yyyy): %expDate% >> "%CERT_INFO_FILE%"
|
||||
echo Certificate and key paths and expiration date stored in %CERT_INFO_FILE%. %outputRedirection%
|
||||
|
||||
24
bin/functions/launch/log_wrapper.bat
Normal file
24
bin/functions/launch/log_wrapper.bat
Normal file
@@ -0,0 +1,24 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM Define the path to the log file
|
||||
set LOG_FILE=..\bin\logs\st_console_output.log
|
||||
|
||||
REM Set necessary environment variables for Node.js
|
||||
set NODE_ENV=production
|
||||
|
||||
REM Determine the command to run
|
||||
if "%1"=="ssl" (
|
||||
set NODE_CMD=node server.js --ssl
|
||||
) else (
|
||||
set NODE_CMD=node server.js
|
||||
)
|
||||
|
||||
REM Start the Node.js server and log the output using PowerShell Tee-Object, suppressing specific warnings
|
||||
echo Starting Node.js server with command: %NODE_CMD%
|
||||
powershell -Command "& {%NODE_CMD% 2>&1 | Where-Object {$_ -notmatch 'Security has been overridden'} | Tee-Object -FilePath '%LOG_FILE%'}"
|
||||
echo Node.js server started.
|
||||
pause
|
||||
|
||||
REM Pause to keep the window open
|
||||
pause
|
||||
33
bin/functions/troubleshooting/fetch_title.js
Normal file
33
bin/functions/troubleshooting/fetch_title.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var x = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
var url = WScript.Arguments(0);
|
||||
var timeout = 5000; // 5 seconds timeout
|
||||
var startTime = new Date().getTime();
|
||||
|
||||
x.open("GET", url, false);
|
||||
x.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
||||
|
||||
try {
|
||||
x.send('');
|
||||
while (x.readyState != 4) {
|
||||
if (new Date().getTime() - startTime > timeout) {
|
||||
throw new Error("Request timed out");
|
||||
}
|
||||
WScript.Sleep(50);
|
||||
}
|
||||
|
||||
if (x.status == 200) {
|
||||
var responseText = x.responseText;
|
||||
var matches = responseText.match(/<title>(.*?)<\/title>/i);
|
||||
if (matches && matches[1]) {
|
||||
WScript.Echo(matches[1]);
|
||||
} else {
|
||||
WScript.Echo("Title tag not found");
|
||||
}
|
||||
} else if (x.status == 404) {
|
||||
WScript.Echo("No User Accessible Web Application running on port, May be an API (404 Not Found)");
|
||||
} else {
|
||||
WScript.Echo("HTTP Error: " + x.status);
|
||||
}
|
||||
} catch (e) {
|
||||
WScript.Echo(e.message);
|
||||
}
|
||||
Reference in New Issue
Block a user