Skip to content

Commit d2f3fa9

Browse files
Create build_windows.bat
1 parent 819d578 commit d2f3fa9

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

build_windows.bat

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
@echo off
2+
setlocal
3+
4+
set README_URL=https://github.com/oracle-quickstart/db-endpoint-latency-testing-ammeter/blob/main/README.md
5+
6+
echo [1/5] Creating Python virtual environment (.venv)...
7+
if not exist .venv (
8+
python -m venv .venv
9+
if errorlevel 1 (
10+
echo Failed to create venv. Please check your Python installation.
11+
echo Refer to manual setup: %README_URL%
12+
exit /b 1
13+
)
14+
) else (
15+
echo Virtual environment already exists.
16+
)
17+
18+
echo [2/5] Activating virtual environment...
19+
call .venv\Scripts\activate
20+
if errorlevel 1 (
21+
echo Failed to activate virtual environment.
22+
echo Refer to manual setup: %README_URL%
23+
exit /b 1
24+
)
25+
26+
echo [3/5] Installing requirements from requirements.txt...
27+
pip install --upgrade pip
28+
if errorlevel 1 (
29+
echo Failed to upgrade pip.
30+
echo Refer to manual setup: %README_URL%
31+
exit /b 1
32+
)
33+
pip install -r requirements.txt
34+
if errorlevel 1 (
35+
echo Failed to install dependencies.
36+
echo Refer to manual setup: %README_URL%
37+
exit /b 1
38+
)
39+
40+
echo [4/5] Generating self-signed SSL certificate if not present...
41+
set SSL_DIR=ssl
42+
set KEY_FILE=%SSL_DIR%\key.pem
43+
set CERT_FILE=%SSL_DIR%\cert.pem
44+
45+
if not exist %SSL_DIR% (
46+
mkdir %SSL_DIR%
47+
)
48+
49+
if exist %KEY_FILE% if exist %CERT_FILE% (
50+
echo SSL certificate and key found.
51+
) else (
52+
where openssl > nul 2>&1
53+
if errorlevel 1 (
54+
echo OpenSSL is required for SSL certificate generation but is not installed or not in PATH.
55+
echo Refer to manual setup: %README_URL%
56+
exit /b 1
57+
)
58+
openssl req -x509 -nodes -days 825 -newkey rsa:2048 ^
59+
-keyout %KEY_FILE% -out %CERT_FILE% ^
60+
-subj "/C=US/ST=Self/L=Self/O=Self/CN=localhost"
61+
if errorlevel 1 (
62+
echo Failed to generate SSL certificate.
63+
echo Refer to manual setup: %README_URL%
64+
exit /b 1
65+
)
66+
)
67+
68+
echo [5/5] Launching app with uvicorn (https://localhost:8000, self-signed SSL)...
69+
uvicorn app.main:app --host 0.0.0.0 --port 8000 --ssl-keyfile "%KEY_FILE%" --ssl-certfile "%CERT_FILE%"
70+
if errorlevel 1 (
71+
echo Failed to launch the app. Please check above for errors.
72+
echo Refer to manual setup: %README_URL%
73+
exit /b 1
74+
)
75+
76+
endlocal

0 commit comments

Comments
 (0)