const http = require('http'); const PORT = process.env.PORT || 3000; const COLOR = process.env.DEPLOY_COLOR || 'unknown'; const VERSION = process.env.npm_package_version || '1.0.0'; const server = http.createServer((req, res) => { const url = req.url; // 健康检查端点 if (url === '/health') { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ status: 'healthy', color: COLOR, version: VERSION, timestamp: new Date().toISOString(), uptime: process.uptime() })); return; } // 主页 res.writeHead(200, { 'Content-Type': 'text/html' }); res.end(` gch3n.online

🚀 gch3n.online

${COLOR}

蓝绿部署示例应用

版本: ${VERSION}

端口: ${PORT}

时间: ${new Date().toLocaleString('zh-CN')}

`); }); server.listen(PORT, () => { console.log(`🚀 服务器运行在端口 ${PORT}`); console.log(`🎨 部署颜色: ${COLOR}`); console.log(`📦 版本: ${VERSION}`); });