-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-server.ps1
More file actions
49 lines (43 loc) · 2.37 KB
/
Copy pathrun-server.ps1
File metadata and controls
49 lines (43 loc) · 2.37 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
# gscribe 프로덕션 서버 기동 스크립트 (Windows / PowerShell)
#
# 사용법:
# 1) frontend/dist 가 있어야 함 (다른 PC에서 `npm run build` 후 복사)
# 2) .env 에 DEEPGRAM_API_KEY, ANTHROPIC_API_KEY 설정
# 3) PowerShell 에서: .\run-server.ps1
#
# 환경변수로 호스트/포트 조정 가능: $env:GSCRIBE_PORT = "9000"; .\run-server.ps1
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
$bind = if ($env:GSCRIBE_HOST) { $env:GSCRIBE_HOST } else { "0.0.0.0" }
$port = if ($env:GSCRIBE_PORT) { $env:GSCRIBE_PORT } else { "8000" }
# .env 를 프로세스 환경변수로 로드 (app.py 의 load_dotenv 와 별개로 명시 로드)
if (Test-Path ".env") {
Get-Content ".env" | ForEach-Object {
if ($_ -match '^\s*([^#=]+)=(.+)$') { Set-Item "env:$($matches[1].Trim())" $matches[2].Trim() }
}
}
# 사전 점검
if (-not (Get-Command ffmpeg -ErrorAction SilentlyContinue)) {
Write-Warning "ffmpeg 이 PATH 에 없습니다. 압축 없이 원본을 전송합니다(동작은 함)."
}
if (-not (Test-Path "frontend/dist/index.html")) {
Write-Warning "frontend/dist 가 없습니다. '/' 는 500 을 반환합니다. 다른 PC에서 'npm run build' 후 dist 를 복사하세요."
}
if (-not $env:DEEPGRAM_API_KEY) { throw "DEEPGRAM_API_KEY 미설정 (.env 확인)" }
if (-not $env:ANTHROPIC_API_KEY) { throw "ANTHROPIC_API_KEY 미설정 (.env 확인)" }
# 인증서(cert.pem/key.pem)가 있으면 HTTPS 로 구동한다.
# 마이크 녹음(getUserMedia)은 보안 컨텍스트에서만 동작하므로, LAN IP 로 접속하는
# 태블릿/모바일에서 녹음하려면 HTTPS 가 필수다. 인증서는 `python gen_cert.py <IP>` 로 생성.
$sslArgs = @()
$scheme = "http"
if ((Test-Path "cert.pem") -and (Test-Path "key.pem")) {
$sslArgs = @("--ssl-certfile", "cert.pem", "--ssl-keyfile", "key.pem")
$scheme = "https"
if (-not $env:GSCRIBE_PORT) { $port = "8443" } # HTTPS 기본 포트
}
Write-Host "gscribe 서버 시작: ${scheme}://${bind}:${port}"
if ($scheme -eq "http") {
Write-Warning "HTTP 모드 — 마이크 녹음은 localhost 에서만 됩니다. LAN 기기 녹음은 'python gen_cert.py <이 PC IP>' 로 인증서 생성 후 재실행하세요(HTTPS)."
}
# 프로덕션: --reload 없이 구동. 동시 처리량이 필요하면 --workers 2~4 추가.
python -m uvicorn app:app --host $bind --port $port --log-level info @sslArgs