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(`
蓝绿部署示例应用
版本: ${VERSION}
端口: ${PORT}
时间: ${new Date().toLocaleString('zh-CN')}