forked from ace-step/ACE-Step-1.5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_api_server.bat
More file actions
257 lines (227 loc) · 8.67 KB
/
Copy pathstart_api_server.bat
File metadata and controls
257 lines (227 loc) · 8.67 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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
@echo off
setlocal enabledelayedexpansion
REM ACE-Step REST API Server Launcher
REM This script launches the REST API server for ACE-Step
REM ==================== Configuration ====================
REM Uncomment and modify the parameters below as needed
REM Server settings
set HOST=127.0.0.1
REM set HOST=0.0.0.0
set PORT=8001
REM API key for authentication (optional)
REM set API_KEY=--api-key sk-your-secret-key
REM Download source settings
REM Preferred download source: auto (default), huggingface, or modelscope
REM set DOWNLOAD_SOURCE=--download-source modelscope
REM set DOWNLOAD_SOURCE=--download-source huggingface
set DOWNLOAD_SOURCE=
REM Update check settings (for portable package users with PortableGit)
REM Check for updates from GitHub before starting
set CHECK_UPDATE=false
REM set CHECK_UPDATE=true
REM ==================== Launch ====================
REM Check for updates if enabled
if /i "%CHECK_UPDATE%"=="true" (
echo Checking for updates...
echo.
if exist "%~dp0check_update.bat" (
if exist "%~dp0PortableGit\bin\git.exe" (
call "%~dp0check_update.bat"
set UPDATE_CHECK_RESULT=%ERRORLEVEL%
if !UPDATE_CHECK_RESULT! EQU 1 (
echo.
echo [Error] Update check failed.
echo Continuing with startup...
echo.
) else if !UPDATE_CHECK_RESULT! EQU 2 (
echo.
echo [Info] Update check skipped (network timeout).
echo Continuing with startup...
echo.
)
REM Wait a moment before starting
timeout /t 2 /nobreak >nul
) else (
echo [Info] PortableGit not found, skipping update check.
echo To enable update checks, install PortableGit in the PortableGit folder.
echo.
)
) else (
echo [Info] check_update.bat not found, skipping update check.
echo.
)
)
echo Starting ACE-Step REST API Server...
echo API will be available at: http://%HOST%:%PORT%
echo API Documentation: http://%HOST%:%PORT%/docs
echo.
REM Auto-detect Python environment
if exist "%~dp0python_embeded\python.exe" (
echo [Environment] Using embedded Python...
"%~dp0python_embeded\python.exe" "%~dp0acestep\api_server.py" ^
--host %HOST% ^
--port %PORT% ^
%API_KEY% ^
%DOWNLOAD_SOURCE%
) else (
echo [Environment] Embedded Python not found, checking for uv...
REM Check if uv is installed
where uv >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo.
echo ========================================
echo uv package manager not found!
echo ========================================
echo.
echo ACE-Step requires either:
echo 1. python_embeded directory (portable package)
echo 2. uv package manager
echo.
echo Would you like to install uv now? (Recommended)
echo.
set /p INSTALL_UV="Install uv? (Y/N): "
if /i "%INSTALL_UV%"=="Y" (
echo.
echo Installing uv...
echo.
REM Try winget first (Windows 10 1809+ / Windows 11)
where winget >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo [Method 1] Using winget (Windows Package Manager)...
echo.
winget install --id=astral-sh.uv -e --silent
if %ERRORLEVEL% EQU 0 (
echo.
echo ========================================
echo uv installed successfully via winget!
echo ========================================
goto :CheckUvInstallation
) else (
echo.
echo winget installation failed, trying PowerShell...
)
) else (
echo [Info] winget not available, using PowerShell...
)
REM Fallback to PowerShell
echo [Method 2] Using PowerShell...
echo This may take a few moments...
echo.
powershell -NoProfile -ExecutionPolicy Bypass -Command "& {try { Invoke-RestMethod https://astral.sh/uv/install.ps1 | Invoke-Expression; Write-Host 'uv installed successfully!' -ForegroundColor Green } catch { Write-Host 'Installation failed. Please install manually.' -ForegroundColor Red; exit 1 }}"
if %ERRORLEVEL% NEQ 0 (
echo.
echo ========================================
echo Installation failed!
echo ========================================
echo.
echo Please install uv manually:
echo 1. Using winget: winget install --id=astral-sh.uv -e
echo 2. Using PowerShell: irm https://astral.sh/uv/install.ps1 ^| iex
echo 3. Download portable package: https://files.acemusic.ai/acemusic/win/ACE-Step-1.5.7z
echo.
pause
exit /b 1
)
:CheckUvInstallation
echo.
echo ========================================
echo uv installed successfully!
echo ========================================
echo.
echo Refreshing environment...
REM Refresh PATH to include uv
REM Check common installation locations
if exist "%USERPROFILE%\.local\bin\uv.exe" (
set "PATH=%USERPROFILE%\.local\bin;%PATH%"
)
if exist "%LOCALAPPDATA%\Microsoft\WinGet\Links\uv.exe" (
set "PATH=%LOCALAPPDATA%\Microsoft\WinGet\Links;%PATH%"
)
REM Verify uv is now available
where uv >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo uv is now available!
uv --version
echo.
goto :RunWithUv
) else (
REM Try direct paths
if exist "%USERPROFILE%\.local\bin\uv.exe" (
"%USERPROFILE%\.local\bin\uv.exe" --version >nul 2>&1
if %ERRORLEVEL% EQU 0 (
set "PATH=%USERPROFILE%\.local\bin;%PATH%"
echo uv is now available!
echo.
goto :RunWithUv
)
)
if exist "%LOCALAPPDATA%\Microsoft\WinGet\Links\uv.exe" (
"%LOCALAPPDATA%\Microsoft\WinGet\Links\uv.exe" --version >nul 2>&1
if %ERRORLEVEL% EQU 0 (
set "PATH=%LOCALAPPDATA%\Microsoft\WinGet\Links;%PATH%"
echo uv is now available!
echo.
goto :RunWithUv
)
)
echo.
echo uv installed but not in PATH yet.
echo Please restart your terminal or run:
echo %USERPROFILE%\.local\bin\uv.exe run acestep-api
echo.
pause
exit /b 1
)
) else (
echo.
echo Installation cancelled.
echo.
echo To use ACE-Step, please either:
echo 1. Install uv: winget install --id=astral-sh.uv -e
echo 2. Download portable package: https://files.acemusic.ai/acemusic/win/ACE-Step-1.5.7z
echo.
pause
exit /b 1
)
)
:RunWithUv
echo [Environment] Using uv package manager...
echo.
REM Check if virtual environment exists
if not exist "%~dp0.venv" (
echo [Setup] Virtual environment not found. Setting up environment...
echo This will take a few minutes on first run.
echo.
echo Running: uv sync
echo.
uv sync
if %ERRORLEVEL% NEQ 0 (
echo.
echo ========================================
echo [Error] Failed to setup environment
echo ========================================
echo.
echo Please check the error messages above.
echo You may need to:
echo 1. Check your internet connection
echo 2. Ensure you have enough disk space
echo 3. Try running: uv sync manually
echo.
pause
exit /b 1
)
echo.
echo ========================================
echo Environment setup completed!
echo ========================================
echo.
)
echo Starting ACE-Step API Server...
echo.
uv run acestep-api ^
--host %HOST% ^
--port %PORT% ^
%API_KEY% ^
%DOWNLOAD_SOURCE%
)
pause