-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_postgres.bat
More file actions
73 lines (64 loc) · 2.03 KB
/
start_postgres.bat
File metadata and controls
73 lines (64 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@echo off
echo ===================================================
echo Secure Authentication System - PostgreSQL Launcher
echo ===================================================
echo.
REM Update these paths to match your PostgreSQL portable installation
SET PGPORT=5432
SET PGDATA=%~dp0pgdata
SET PGBIN=C:\path\to\your\portable\pgsql\bin
echo IMPORTANT: Before first use, update this file with the correct path to your PostgreSQL bin directory
echo Current settings:
echo PostgreSQL bin directory: %PGBIN%
echo Port: %PGPORT%
echo Data directory: %PGDATA%
echo.
REM Check if bin directory exists
IF NOT EXIST "%PGBIN%" (
echo ERROR: PostgreSQL bin directory not found at %PGBIN%
echo Please edit this file and set the correct path to your PostgreSQL bin directory.
echo.
pause
exit /b 1
)
REM Check if data directory exists
IF NOT EXIST "%PGDATA%" (
echo First-time setup: Initializing PostgreSQL database...
echo.
mkdir "%PGDATA%"
"%PGBIN%\initdb.exe" -D "%PGDATA%" -E UTF8 -U postgres
IF NOT %ERRORLEVEL% == 0 (
echo ERROR: Failed to initialize database.
echo.
pause
exit /b 1
)
echo Database initialized successfully!
echo.
)
REM Start PostgreSQL server
echo Starting PostgreSQL server...
"%PGBIN%\pg_ctl.exe" -D "%PGDATA%" -l "%PGDATA%\postgresql.log" start
IF %ERRORLEVEL% == 0 (
echo.
echo PostgreSQL is now running on port %PGPORT%
echo Data directory: %PGDATA%
echo Log file: %PGDATA%\postgresql.log
echo.
echo After PostgreSQL is running, follow these steps:
echo 1. Run: python init_db.py
echo 2. Run: python create_admin.py admin admin@example.com YourStrongPassword123!
echo 3. Run: python app.py
echo.
echo Press any key to stop the PostgreSQL server when you're done.
echo.
pause
echo Stopping PostgreSQL server...
"%PGBIN%\pg_ctl.exe" -D "%PGDATA%" stop
) ELSE (
echo.
echo ERROR: Failed to start PostgreSQL server.
echo Check the log file: %PGDATA%\postgresql.log
echo.
pause
)