Files
forumlify/scripts/start.js
T
lezi-fun 281460fb03 feat: migrate to Next.js 14 (App Router + Route Handlers)
- Replace Express server with Next.js Route Handlers (16 API routes)
- Rewrite index.html SPA as React components (feed, post, admin, modals)
- Move style.css to app/globals.css with dark/light themes intact
- Add lib/db.js, lib/auth.js (JWT), lib/api.js (client API wrapper)
- Server binds 0.0.0.0 by default; host/port configurable via config.js
- Uploads served via /api/uploads route (rewrite keeps /uploads/ URLs)
- Multi-stage dockerfile using standalone output
2026-08-09 17:02:11 +08:00

22 lines
802 B
JavaScript

#!/usr/bin/env node
// Forumlify 启动入口
// 从 config.js 读取 SERVER_HOST / SERVER_PORT(可选),未配置时用默认值:
// host = 环境变量 HOST > config.SERVER_HOST > '0.0.0.0'
// port = 环境变量 PORT > config.SERVER_PORT > 3000
const { spawn } = require('child_process');
const CONFIG = require('../config');
const host = process.env.HOST || CONFIG.SERVER_HOST || '0.0.0.0';
const port = process.env.PORT || CONFIG.SERVER_PORT || 3000;
const args = ['start', '-H', host, '-p', String(port)];
const child = spawn(require.resolve('next/dist/bin/next'), args, {
stdio: 'inherit',
env: { ...process.env, HOSTNAME: host, PORT: String(port) },
});
child.on('exit', (code, signal) => {
if (signal) process.kill(process.pid, signal);
else process.exit(code ?? 0);
});