M5: 포터블 exe 앱 (트레이·설정 창·첫 실행 마법사) + M6 사전 기능
- app/src/main: Electron 메인(트레이 상태 아이콘, 설정 창, 단일 실행, DPAPI safeStorage, 스모크 모드), IPC(window.gvr), 파인튜닝 관리 - app/src/renderer: 설정 8개 탭 + 5단계 첫 실행 마법사 (React) - electron-builder: GameVoiceRecorder.exe, zip(폴더 포터블) + 단일 exe 포터블, 워커·리소스 포함 - 사전: 사이트에서 단어·교정 규칙 추가/삭제(/api/dictionary), 게임 패치 이름 자동 추가, 묶음별 중복 허용 + DB 마이그레이션 - 사이트 서버: 종료 시 WebSocket 먼저 끊기(재시작 멈춤 수정) + 재연결 테스트 - scripts/finetune-e2e.mts, stt-eval.mts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ const SID = 'gvr_sid';
|
||||
const RECHECK_MS = 10 * 60000;
|
||||
|
||||
export async function buildServer(cfg: Config) {
|
||||
const app = Fastify({ logger: { level: process.env.LOG_LEVEL || 'info' }, trustProxy: true, bodyLimit: 1024 * 1024 });
|
||||
const app = Fastify({ logger: { level: process.env.LOG_LEVEL || 'info' }, trustProxy: true, bodyLimit: 1024 * 1024, forceCloseConnections: true });
|
||||
const store = new ServerStore(cfg.dataDir);
|
||||
const hub = new RelayHub(store);
|
||||
const discord = new DiscordApi(cfg);
|
||||
@@ -206,8 +206,11 @@ export async function buildServer(cfg: Config) {
|
||||
socket.destroy();
|
||||
});
|
||||
|
||||
app.addHook('onClose', async () => {
|
||||
// 서버를 닫기 전에 WebSocket 을 먼저 끊는다 (안 끊으면 close 가 연결이 끝나길 기다리며 멈춘다)
|
||||
app.addHook('preClose', async () => {
|
||||
hub.close();
|
||||
});
|
||||
app.addHook('onClose', async () => {
|
||||
store.flush();
|
||||
});
|
||||
|
||||
|
||||
50
site/server/test/reconnect.test.ts
Normal file
50
site/server/test/reconnect.test.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { buildServer } from '../src/app.ts';
|
||||
import type { Config } from '../src/config.ts';
|
||||
|
||||
// M7 안정화: 사이트 서버가 재시작(배포)돼도 게임 PC 연결이 자동으로 돌아오는지
|
||||
test('사이트 서버 재시작 → 게임 PC 자동 재연결', async () => {
|
||||
const dataDir = fs.mkdtempSync(path.join(process.env.TMPDIR || os.tmpdir(), 'gvr-rc-'));
|
||||
const cfg = (port: number): Config => ({
|
||||
port, host: '127.0.0.1', publicUrl: 'http://127.0.0.1', clientId: 'x', clientSecret: 'x', botToken: 'x', allowedGuilds: [], owners: [],
|
||||
sessionSecret: 'y'.repeat(32), dataDir, webDir: '/nonexistent', version: 't', discordApi: 'http://127.0.0.1:1', assetUpstream: {},
|
||||
});
|
||||
let s = await buildServer(cfg(0));
|
||||
s.app.log.level = 'silent';
|
||||
await s.app.listen({ host: '127.0.0.1', port: 0 });
|
||||
const port = (s.app.server.address() as any).port;
|
||||
const base = `http://127.0.0.1:${port}`;
|
||||
const code = s.store.createCode('t');
|
||||
const reg = (await (await fetch(base + '/device/register', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ code: code.code, name: 'PC' }) })).json()) as any;
|
||||
const { RelayClient } = await import('../../../app/src/core/relay/client.ts');
|
||||
const { Bus } = await import('../../../app/src/core/util/events.ts');
|
||||
const Fastify = (await import('fastify')).default;
|
||||
const local = Fastify();
|
||||
const rc = new RelayClient(local as any, new Bus(), () => ({ serverUrl: base, deviceId: reg.deviceId, deviceKey: reg.deviceKey, name: 'PC', version: '1', guildId: null }));
|
||||
rc.start();
|
||||
const wait = async (fn: () => boolean, ms: number, label: string) => {
|
||||
const t = Date.now();
|
||||
while (!fn()) {
|
||||
if (Date.now() - t > ms) throw new Error('timeout ' + label);
|
||||
await new Promise((r) => setTimeout(r, 50));
|
||||
}
|
||||
};
|
||||
await wait(() => rc.status.state === 'online', 5000, 'first');
|
||||
await s.app.close();
|
||||
await wait(() => rc.status.state !== 'online', 5000, 'drop');
|
||||
const dropAt = Date.now();
|
||||
await new Promise((r) => setTimeout(r, 1500));
|
||||
s = await buildServer(cfg(port));
|
||||
s.app.log.level = 'silent';
|
||||
await s.app.listen({ host: '127.0.0.1', port });
|
||||
await wait(() => rc.status.state === 'online', 20000, 'reconnect');
|
||||
console.log(`재연결까지 ${((Date.now() - dropAt) / 1000).toFixed(1)}초`);
|
||||
assert.equal(s.hub.status().online, true, '서버도 기기를 온라인으로 본다');
|
||||
rc.stop();
|
||||
await s.app.close();
|
||||
await local.close();
|
||||
});
|
||||
Reference in New Issue
Block a user