-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_postgres.bat
More file actions
65 lines (55 loc) · 1.75 KB
/
start_postgres.bat
File metadata and controls
65 lines (55 loc) · 1.75 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
@echo off
REM PostgreSQL Startup Script for Arrest Data Application
echo === PostgreSQL Startup Script ===
echo.
REM Check if Docker is running
docker info >nul 2>&1
if errorlevel 1 (
echo ❌ Docker is not running. Please start Docker and try again.
pause
exit /b 1
)
echo ✅ Docker is running
REM Check if docker-compose is available
docker-compose --version >nul 2>&1
if errorlevel 1 (
echo ❌ docker-compose is not installed. Please install Docker Compose.
pause
exit /b 1
)
echo ✅ Docker Compose is available
REM Start PostgreSQL container
echo.
echo 🚀 Starting PostgreSQL container...
docker-compose up -d postgres
REM Wait for PostgreSQL to be ready
echo ⏳ Waiting for PostgreSQL to be ready...
timeout /t 10 /nobreak >nul
REM Check if PostgreSQL is running
docker-compose ps postgres | findstr "Up" >nul
if errorlevel 1 (
echo ❌ PostgreSQL container failed to start
echo Check logs with: docker-compose logs postgres
pause
exit /b 1
) else (
echo ✅ PostgreSQL container is running
)
REM Check if we can connect to PostgreSQL
echo 🔍 Testing PostgreSQL connection...
python -c "import psycopg2; conn = psycopg2.connect(host='localhost', port=5432, database='arrest_data', user='arrest_user', password='arrest_password'); conn.close(); print('✅ PostgreSQL connection successful')" 2>nul
if errorlevel 1 (
echo ❌ Cannot connect to PostgreSQL
pause
exit /b 1
) else (
echo ✅ PostgreSQL is ready for connections
)
echo.
echo 🎉 Setup complete! You can now start your application:
echo python run_server.py
echo.
echo 📊 To view PostgreSQL logs: docker-compose logs postgres
echo 🛑 To stop PostgreSQL: docker-compose down
echo 🔄 To restart PostgreSQL: docker-compose restart postgres
pause