| 2127 | |
| 2128 | // Build job status response for the local machine |
| 2129 | const getJobStatusPayload = () => { |
| 2130 | const mem = process.memoryUsage(); |
| 2131 | return { |
| 2132 | processRole, |
| 2133 | uptime: Math.round(process.uptime()), |
| 2134 | memory: { |
| 2135 | rss: `${Math.round(mem.rss / 1024 / 1024)}MB`, |
| 2136 | heapUsed: `${Math.round(mem.heapUsed / 1024 / 1024)}MB`, |
| 2137 | heapTotal: `${Math.round(mem.heapTotal / 1024 / 1024)}MB`, |
| 2138 | }, |
| 2139 | jobs: jobScheduler.getStatus().map(j => ({ |
| 2140 | ...j, |
| 2141 | lastError: j.lastError ? j.lastError.substring(0, 200) : null, |
| 2142 | })), |
| 2143 | }; |
| 2144 | }; |
| 2145 | |
| 2146 | // Internal endpoint — no auth, only served on worker machines. |
| 2147 | // The worker's port is not publicly routable (no http_service). |