-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathstart_dream_layer.bat
More file actions
242 lines (205 loc) · 8.97 KB
/
start_dream_layer.bat
File metadata and controls
242 lines (205 loc) · 8.97 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
@echo off
setlocal enabledelayedexpansion
:: Dream Layer Windows Startup Script
:: This script starts all the necessary services for the Dream Layer application on Windows
:: Colors for output (basic)
set "RED=[91m"
set "GREEN=[92m"
set "YELLOW=[93m"
set "BLUE=[94m"
set "CYAN=[96m"
set "NC=[0m"
echo.
echo %CYAN%================================================%NC%
echo %CYAN% DREAM LAYER - WINDOWS STARTUP%NC%
echo %CYAN%================================================%NC%
echo.
:: Check if we're in the correct directory
if not exist "dream_layer_backend" (
echo %RED%[ERROR]%NC% This script must be run from the Dream Layer project root directory!
echo %RED%[ERROR]%NC% Please navigate to the 'DreamLayer' folder and run this script again.
echo %YELLOW%[INFO]%NC% Current directory: %CD%
echo %YELLOW%[INFO]%NC% Expected files: dream_layer_backend, dream_layer_frontend, ComfyUI
echo.
pause
exit /b 1
)
:: Create logs directory if it doesn't exist
if not exist "logs" mkdir logs
echo %BLUE%[INFO]%NC% Starting Dream Layer services...
echo %YELLOW%[INFO]%NC% Logs will be saved in the 'logs' directory
echo.
:: Check Python installation
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo %RED%[ERROR]%NC% Python is not installed or not in PATH!
echo %YELLOW%[INFO]%NC% Please run install_windows_dependencies.bat first
pause
exit /b 1
)
:: Check Node.js installation
node --version >nul 2>&1
if %errorlevel% neq 0 (
echo %RED%[ERROR]%NC% Node.js is not installed or not in PATH!
echo %YELLOW%[INFO]%NC% Please run install_windows_dependencies.bat first
pause
exit /b 1
)
:: Check if PyTorch is installed
python -c "import torch" >nul 2>&1
if %errorlevel% neq 0 (
echo %YELLOW%[WARNING]%NC% PyTorch not found. Installing...
nvidia-smi >nul 2>&1
if %errorlevel% equ 0 (
echo %GREEN%[INFO]%NC% NVIDIA GPU detected - installing PyTorch with CUDA...
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
) else (
echo %YELLOW%[INFO]%NC% No NVIDIA GPU detected - installing CPU-only PyTorch...
python -m pip install torch torchvision torchaudio
)
)
:: Check GPU availability and set CPU mode if needed
echo %BLUE%[INFO]%NC% Checking GPU availability...
:: FORCING CPU MODE FOR COMFYUI
set "DREAMLAYER_COMFYUI_CPU_MODE=true"
set "DEVICE_MODE=CPU"
:: Original logic commented out:
:: nvidia-smi >nul 2>&1
:: if %errorlevel% neq 0 (
:: echo %YELLOW%[INFO]%NC% No NVIDIA GPU detected - ComfyUI will run in CPU mode
:: set "COMFYUI_CPU_MODE=--cpu"
:: set "DEVICE_MODE=CPU"
:: ) else (
:: echo %GREEN%[INFO]%NC% NVIDIA GPU detected - ComfyUI will use GPU acceleration
:: set "COMFYUI_CPU_MODE="
:: set "DEVICE_MODE=GPU"
:: )
:: Check if backend dependencies are installed
python -c "import flask" >nul 2>&1
if %errorlevel% neq 0 (
echo %YELLOW%[WARNING]%NC% Backend dependencies not found. Installing...
cd dream_layer_backend
python -m pip install -r requirements.txt
cd ..
)
:: Check if ComfyUI dependencies are installed
python -c "import sys; sys.path.append('ComfyUI'); import torch" >nul 2>&1
if %errorlevel% neq 0 (
echo %YELLOW%[WARNING]%NC% ComfyUI dependencies not found. Installing...
cd ComfyUI
python -m pip install -r requirements.txt
cd ..
)
:: Check if frontend dependencies are installed
if not exist "dream_layer_frontend\node_modules" (
echo %YELLOW%[WARNING]%NC% Frontend dependencies not found. Installing...
cd dream_layer_frontend
npm install
cd ..
)
echo.
echo %GREEN%[SUCCESS]%NC% All dependencies are ready!
echo %BLUE%[INFO]%NC% Device mode: %DEVICE_MODE%
echo.
:: Start services
echo %CYAN%================================================%NC%
echo %CYAN% STARTING SERVICES%NC%
echo %CYAN%================================================%NC%
echo.
:: Start Dream Layer backend (which also starts ComfyUI internally)
echo %BLUE%[STEP 1/6]%NC% Starting Dream Layer backend...
start "Dream Layer Backend" /D "%CD%" cmd /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python dream_layer_backend\dream_layer.py > logs\dream_layer.log 2>&1"
:: Wait for backend to start
echo %YELLOW%[INFO]%NC% Waiting for backend to initialize...
timeout /t 5 /nobreak >nul
:: Start txt2img_server.py
echo %BLUE%[STEP 2/6]%NC% Starting txt2img_server.py...
start "Txt2Img Server" /D "%CD%\dream_layer_backend" cmd /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python txt2img_server.py > ..\logs\txt2img_server.log 2>&1"
:: Start img2img_server.py
echo %BLUE%[STEP 3/6]%NC% Starting img2img_server.py...
start "Img2Img Server" /D "%CD%\dream_layer_backend" cmd /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python img2img_server.py > ..\logs\img2img_server.log 2>&1"
:: Start extras.py
echo %BLUE%[STEP 4/8]%NC% Starting extras.py...
start "Extras Server" /D "%CD%\dream_layer_backend" cmd /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python extras.py > ..\logs\extras.log 2>&1"
:: Start run registry server
echo %BLUE%[STEP 5/8]%NC% Starting run registry server...
start "Run Registry Server" /D "%CD%\dream_layer_backend" cmd /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python run_registry.py > ..\logs\run_registry.log 2>&1"
:: Start report bundle server
echo %BLUE%[STEP 6/8]%NC% Starting report bundle server...
start "Report Bundle Server" /D "%CD%\dream_layer_backend" cmd /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python report_bundle.py > ..\logs\report_bundle.log 2>&1"
:: Start img2txt_server.py
echo %BLUE%[STEP 7/8]%NC% Starting img2txt_server.py...
start "Img2Txt Server" /D "%CD%\dream_layer_backend" cmd /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python img2txt_server.py > ..\logs\img2txt_server.log 2>&1"
:: Start localtunnel for external API access
where lt >nul 2>&1
if %errorlevel% equ 0 (
start "LocalTunnel" cmd /c "lt --port 5002 > logs\tunnel.log 2>&1"
)
:: Wait for all backend services to start
echo %YELLOW%[INFO]%NC% Waiting for all backend services to initialize...
timeout /t 10 /nobreak >nul
:: Start frontend development server
echo %BLUE%[STEP 8/8]%NC% Starting frontend development server...
start "Dream Layer Frontend" /D "%CD%\dream_layer_frontend" cmd /c "npm run dev > ..\logs\frontend.log 2>&1"
:: Wait for frontend to start
echo %YELLOW%[INFO]%NC% Waiting for frontend to initialize...
timeout /t 15 /nobreak >nul
echo.
echo %GREEN%[SUCCESS]%NC% All services started!
echo.
echo %CYAN%================================================%NC%
echo %CYAN% ACCESS INFORMATION%NC%
echo %CYAN%================================================%NC%
echo.
echo %GREEN%Frontend (Main UI):%NC% http://localhost:8080
echo %GREEN%ComfyUI Interface:%NC% http://localhost:8188
echo %GREEN%Backend API:%NC% http://localhost:5002
echo %GREEN%Run Registry API:%NC% http://localhost:5005
echo %GREEN%Report Bundle API:%NC% http://localhost:5006
echo %GREEN%Img2Txt API:%NC% http://localhost:5007
echo.
echo %BLUE%[INFO]%NC% Device Mode: %DEVICE_MODE%
echo %BLUE%[INFO]%NC% Check logs in the 'logs' directory if you encounter issues
echo.
:: Test service connectivity
echo %BLUE%[INFO]%NC% Testing service connectivity...
echo.
:: Test ComfyUI
timeout /t 5 /nobreak >nul
python -c "import requests; print('ComfyUI Status:', 'OK' if requests.get('http://localhost:8188', timeout=10).status_code == 200 else 'ERROR')" 2>nul
if %errorlevel% neq 0 (
echo %YELLOW%[WARNING]%NC% ComfyUI may still be starting up - please wait a moment
)
:: Test Backend
python -c "import requests; print('Backend Status:', 'OK' if requests.get('http://localhost:5002', timeout=10).status_code == 200 else 'ERROR')" 2>nul
if %errorlevel% neq 0 (
echo %YELLOW%[WARNING]%NC% Backend may still be starting up - please wait a moment
)
:: Test Run Registry
python -c "import requests; print('Run Registry Status:', 'OK' if requests.get('http://localhost:5005/api/runs', timeout=10).status_code == 200 else 'ERROR')" 2>nul
if %errorlevel% neq 0 (
echo %YELLOW%[WARNING]%NC% Run Registry may still be starting up - please wait a moment
)
:: Test Report Bundle
python -c "import requests; print('Report Bundle Status:', 'OK' if requests.get('http://localhost:5006/api/report-bundle/download', timeout=10).status_code == 200 else 'ERROR')" 2>nul
if %errorlevel% neq 0 (
echo %YELLOW%[WARNING]%NC% Report Bundle may still be starting up - please wait a moment
)
echo.
echo %GREEN%Dream Layer is now running! %NC%
echo %CYAN%Open your browser and navigate to: http://localhost:8080%NC%
echo.
echo %YELLOW%[INFO]%NC% To stop all services, close this window or press Ctrl+C
echo %YELLOW%[INFO]%NC% Log files are available in the 'logs' directory
echo.
:: Keep the window open
echo Press any key to stop all services...
pause >nul
:: Cleanup - kill all related processes
echo.
echo %BLUE%[INFO]%NC% Stopping all services...
taskkill /f /im python.exe >nul 2>&1
taskkill /f /im node.exe >nul 2>&1
taskkill /f /im cmd.exe >nul 2>&1
echo %GREEN%[SUCCESS]%NC% All services stopped.
pause