Skip to content

Create build_windows.bat #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions build_windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@echo off
setlocal

set README_URL=https://github.com/oracle-quickstart/db-endpoint-latency-testing-ammeter/blob/main/README.md

echo [1/5] Creating Python virtual environment (.venv)...
if not exist .venv (
python -m venv .venv
if errorlevel 1 (
echo Failed to create venv. Please check your Python installation.
echo Refer to manual setup: %README_URL%
exit /b 1
)
) else (
echo Virtual environment already exists.
)

echo [2/5] Activating virtual environment...
call .venv\Scripts\activate
if errorlevel 1 (
echo Failed to activate virtual environment.
echo Refer to manual setup: %README_URL%
exit /b 1
)

echo [3/5] Installing requirements from requirements.txt...
pip install --upgrade pip
if errorlevel 1 (
echo Failed to upgrade pip.
echo Refer to manual setup: %README_URL%
exit /b 1
)
pip install -r requirements.txt
if errorlevel 1 (
echo Failed to install dependencies.
echo Refer to manual setup: %README_URL%
exit /b 1
)

echo [4/5] Generating self-signed SSL certificate if not present...
set SSL_DIR=ssl
set KEY_FILE=%SSL_DIR%\key.pem
set CERT_FILE=%SSL_DIR%\cert.pem

if not exist %SSL_DIR% (
mkdir %SSL_DIR%
)

if exist %KEY_FILE% if exist %CERT_FILE% (
echo SSL certificate and key found.
) else (
where openssl > nul 2>&1
if errorlevel 1 (
echo OpenSSL is required for SSL certificate generation but is not installed or not in PATH.
echo Refer to manual setup: %README_URL%
exit /b 1
)
openssl req -x509 -nodes -days 825 -newkey rsa:2048 ^
-keyout %KEY_FILE% -out %CERT_FILE% ^
-subj "/C=US/ST=Self/L=Self/O=Self/CN=localhost"
if errorlevel 1 (
echo Failed to generate SSL certificate.
echo Refer to manual setup: %README_URL%
exit /b 1
)
)

echo [5/5] Launching app with uvicorn (https://localhost:8000, self-signed SSL)...
uvicorn app.main:app --host 0.0.0.0 --port 8000 --ssl-keyfile "%KEY_FILE%" --ssl-certfile "%CERT_FILE%"
if errorlevel 1 (
echo Failed to launch the app. Please check above for errors.
echo Refer to manual setup: %README_URL%
exit /b 1
)

endlocal