|
1 | 1 | import 'dotenv/config'; |
2 | 2 |
|
| 3 | +import os from 'node:os'; |
3 | 4 | import path from 'node:path'; |
4 | 5 |
|
5 | 6 | import { validateEnv } from './config/env'; |
@@ -40,14 +41,52 @@ if (env.INSTALL_MODE === 'bypass') { |
40 | 41 | // modules/ 디렉터리는 프로젝트 루트 기준 (apps/api/src → ../../../modules) |
41 | 42 | const MODULES_DIR = path.join(__dirname, '..', '..', '..', 'modules'); |
42 | 43 |
|
| 44 | +// ── 네트워크 인터페이스 IP 수집 ──────────────────────────────── |
| 45 | + |
| 46 | +function getLocalIPs(): string[] { |
| 47 | + const ips: string[] = []; |
| 48 | + for (const ifaces of Object.values(os.networkInterfaces())) { |
| 49 | + for (const iface of ifaces ?? []) { |
| 50 | + // IPv4이고 루프백(127.x)이 아닌 것만 |
| 51 | + if (iface.family === 'IPv4' && !iface.internal) { |
| 52 | + ips.push(iface.address); |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + return ips; |
| 57 | +} |
| 58 | + |
| 59 | +function printSetupBanner(port: number) { |
| 60 | + const ips = getLocalIPs(); |
| 61 | + const lines = [ |
| 62 | + '', |
| 63 | + ' ╔══════════════════════════════════════════════════════╗', |
| 64 | + ' ║ Fieldstack — 설치 마법사 모드 ║', |
| 65 | + ' ╠══════════════════════════════════════════════════════╣', |
| 66 | + ' ║ 아래 주소 중 하나를 브라우저에서 열어 설치를 ║', |
| 67 | + ' ║ 진행해 주세요. ║', |
| 68 | + ' ╠══════════════════════════════════════════════════════╣', |
| 69 | + ` ║ 로컬 → http://localhost:${port}`.padEnd(56) + '║', |
| 70 | + ]; |
| 71 | + for (const ip of ips) { |
| 72 | + lines.push(` ║ 네트워크 → http://${ip}:${port}`.padEnd(56) + '║'); |
| 73 | + } |
| 74 | + if (ips.length === 0) { |
| 75 | + lines.push(' ║ (네트워크 인터페이스를 감지하지 못했습니다)'.padEnd(56) + '║'); |
| 76 | + } |
| 77 | + lines.push(' ╚══════════════════════════════════════════════════════╝'); |
| 78 | + lines.push(''); |
| 79 | + console.log(lines.join('\n')); |
| 80 | +} |
| 81 | + |
43 | 82 | // ── Setup 모드 ───────────────────────────────────────────────── |
44 | 83 | // installed.lock 없고 bypass 아닐 때 → Setup 마법사만 서빙 |
45 | 84 | async function startSetup() { |
46 | 85 | console.log('[fieldstack][api] *** SETUP MODE — installation wizard active ***'); |
47 | 86 | const app = createSetupApp(); |
48 | 87 | finalizeApp(app); |
49 | 88 | app.listen(env.PORT, () => { |
50 | | - console.log(`[fieldstack][api] setup server listening on http://localhost:${env.PORT}`); |
| 89 | + printSetupBanner(env.PORT); |
51 | 90 | }); |
52 | 91 | } |
53 | 92 |
|
|
0 commit comments