-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.bat
More file actions
129 lines (113 loc) · 2.82 KB
/
start.bat
File metadata and controls
129 lines (113 loc) · 2.82 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@echo off
REM ==================================================
REM MyHouse OS - All-in-One Startup Script (Windows)
REM ==================================================
REM
REM This script will:
REM 1. Pull latest Docker images
REM 2. Start Docker containers in background
REM 3. Wait for services to be ready
REM 4. Open URLs in browser
REM 5. Launch ESP32 Simulator
REM
REM ==================================================
echo.
echo ========================================
echo MyHouse OS - Startup Script
echo ========================================
echo.
REM Check if Docker is running
docker info >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Docker is not running!
echo Please start Docker Desktop and try again.
pause
exit /b 1
)
echo [1/5] Pulling latest images...
echo.
docker compose pull
if %errorlevel% neq 0 (
echo.
echo [WARNING] Could not pull latest images, using cached versions...
echo.
)
echo.
echo [2/5] Starting Docker containers...
echo.
docker compose up -d
if %errorlevel% neq 0 (
echo.
echo [ERROR] Failed to start Docker containers!
pause
exit /b 1
)
echo.
echo [3/5] Waiting for services to be ready...
echo.
REM Wait for API to be ready (max 90 seconds)
set /a counter=0
:waitapi
set /a counter+=1
curl -s http://localhost:3000 >nul 2>&1
if %errorlevel% equ 0 (
echo [OK] API is ready!
goto dashboardwait
)
if %counter% geq 90 (
echo [TIMEOUT] API took too long to start
goto dashboardwait
)
echo Waiting for API... (%counter%/90^)
timeout /t 1 /nobreak >nul
goto waitapi
:dashboardwait
set /a counter=0
:waitdash
set /a counter+=1
curl -s http://localhost:8080 >nul 2>&1
if %errorlevel% equ 0 (
echo [OK] Dashboard is ready!
goto openurls
)
if %counter% geq 90 (
echo [TIMEOUT] Dashboard took too long to start
goto openurls
)
echo Waiting for Dashboard... (%counter%/90^)
timeout /t 1 /nobreak >nul
goto waitdash
:openurls
echo.
echo [4/5] Opening URLs in browser...
echo.
start http://localhost:3000
timeout /t 1 /nobreak >nul
start http://localhost:3000/swagger
timeout /t 1 /nobreak >nul
start http://localhost:8080/login
echo [OK] URLs opened:
echo - API: http://localhost:3000
echo - Swagger: http://localhost:3000/swagger
echo - Dashboard: http://localhost:8080/login
echo.
echo [5/5] Starting ESP32 Simulator...
echo.
echo ========================================
echo Ready! Press Ctrl+C to stop simulator
echo ========================================
echo.
bun scripts\esp-simulator.js
REM When simulator exits, ask if user wants to stop containers
echo.
echo.
set /p stop="Do you want to stop Docker containers? (y/n): "
if /i "%stop%"=="y" (
echo.
echo Stopping Docker containers...
docker compose down
echo Done!
)
echo.
echo Goodbye!
pause