# Actor Standby Mode Reference ## Readiness and access boundaries The examples are minimal sketches, not a production server. Bind the platform-designated host/port, expose only intended routes, authenticate non-probe operations, and return 503 until ready. A caller-supplied probe header is not authentication. Do not serve the workspace through a generic static handler. Standby can create billed cloud runs; configure scaling, deadlines and limits deliberately. ## JavaScript and TypeScript - **NEVER disable standby mode (`usesStandbyMode: false`) in `.actor/actor.json` without explicit permission** - Actor Standby mode solves this problem by letting you have the Actor ready in the background, waiting for the incoming HTTP requests. In a sense, the Actor behaves like a real-time web server or standard API server instead of running the logic once to process everything in batch. Preserve an existing authorized setting; enable standby only when the use case, cost and endpoint authorization require it - **ALWAYS implement readiness probe handler for standby Actors** - Handle the `x-apify-container-server-readiness-probe` header at GET / endpoint to ensure proper Actor lifecycle management You can recognize a standby Actor by checking the `usesStandbyMode` property in `.actor/actor.json`. Only implement the readiness probe if this property is set to `true`. ### Readiness Probe Implementation Example ```javascript // Apify standby readiness probe at root path app.get('/', (req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); if (req.headers['x-apify-container-server-readiness-probe']) { res.end('Readiness probe OK\n'); } else { res.end('Actor is ready\n'); } }); ``` Key points: - Detect the `x-apify-container-server-readiness-probe` header in incoming requests - Return 200 for readiness only after required initialization completes; normal request status must reflect the actual route/auth/result - This enables proper Actor lifecycle management in standby mode ## Python - **NEVER disable standby mode (`usesStandbyMode: false`) in `.actor/actor.json` without explicit permission** - Actor Standby mode solves this problem by letting you have the Actor ready in the background, waiting for the incoming HTTP requests. In a sense, the Actor behaves like a real-time web server or standard API server instead of running the logic once to process everything in batch. Preserve an existing authorized setting; enable standby only when the use case, cost and endpoint authorization require it - **ALWAYS implement readiness probe handler for standby Actors** - Handle the `x-apify-container-server-readiness-probe` header at GET / endpoint to ensure proper Actor lifecycle management You can recognize a standby Actor by checking the `usesStandbyMode` property in `.actor/actor.json`. Only implement the readiness probe if this property is set to `true`. ### Readiness Probe Implementation Example ```python # Apify standby readiness probe from http.server import BaseHTTPRequestHandler class GetHandler(BaseHTTPRequestHandler): def do_GET(self): # Handle Apify standby readiness probe if 'x-apify-container-server-readiness-probe' in self.headers: self.send_response(200) self.end_headers() self.wfile.write(b'Readiness probe OK') return self.send_response(200) self.end_headers() self.wfile.write(b'Actor is ready') ``` Key points: - Detect the `x-apify-container-server-readiness-probe` header in incoming requests - Return 200 for readiness only after required initialization completes; normal request status must reflect the actual route/auth/result - This enables proper Actor lifecycle management in standby mode