| |
| FROM node:24.8.0 |
|
|
| |
| EXPOSE 7860 |
|
|
| |
| ENV N8N_PORT=7860 |
| ENV WEBHOOK_URL=https://stnh70-n8n2.hf.space/ |
| ENV VUE_APP_URL_BASE_API=https://stnh70-n8n2.hf.space/ |
|
|
| |
| RUN npm install n8n -g |
|
|
| |
| RUN mkdir -p /app |
|
|
| |
| COPY <<EOF /app/start-with-heartbeat.js |
| const { spawn } = require('child_process'); |
|
|
| // Periodic heartbeat to confirm event loop activity (can be removed later) |
| let hbCount = 0; |
| setInterval(()=>{ |
| hbCount++; |
| if (hbCount % 6 === 0) { // every 60s if interval is 10s |
| console.log('[diagnostic] heartbeat 60s elapsed, process alive'); |
| } |
| }, 10_000).unref(); |
|
|
| // 启动 n8n |
| console.log('[diagnostic] Starting n8n with heartbeat monitoring...'); |
| const n8nProcess = spawn('n8n', ['start'], { |
| stdio: 'inherit', |
| env: process.env |
| }); |
|
|
| // 处理进程退出 |
| n8nProcess.on('exit', (code, signal) => { |
| console.log(\`[diagnostic] n8n process exited with code \${code}, signal \${signal}\`); |
| process.exit(code); |
| }); |
|
|
| // 处理脚本退出时的信号 |
| process.on('SIGTERM', () => { |
| console.log('[diagnostic] Received SIGTERM, shutting down gracefully...'); |
| n8nProcess.kill('SIGTERM'); |
| }); |
|
|
| process.on('SIGINT', () => { |
| console.log('[diagnostic] Received SIGINT, shutting down gracefully...'); |
| n8nProcess.kill('SIGINT'); |
| }); |
| EOF |
|
|
|
|
| |
| CMD ["node", "/app/start-with-heartbeat.js"] |