You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documents new process readiness features from PR #273:
- Process.waitFor() method for waiting on conditions
- startProcess() ready/readyTimeout options
- serve() method for starting servers with readiness checks
Updates:
- Commands API reference with new methods and options
- Background processes guide with readiness patterns
- Examples showing string, regex, and port-based waiting
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
const { url, process } = await sandbox.serve('npm start', {
204
+
port: 3000,
205
+
hostname: request.headers.get('host'),
206
+
ready: /Server listening/ // Optional: also wait for log pattern
207
+
});
208
+
209
+
console.log('Preview URL:', url);
210
+
console.log('Process ID:', process.id);
211
+
```
212
+
</TypeScriptExample>
213
+
162
214
## Keep containers alive for long-running processes
163
215
164
216
By default, containers automatically shut down after 10 minutes of inactivity. For long-running processes that may have idle periods (like CI/CD pipelines, batch jobs, or monitoring tasks), use the [`keepAlive` option](/sandbox/configuration/sandbox-options/#keepalive):
@@ -207,7 +259,8 @@ When using `keepAlive: true`, containers will not automatically timeout. You **m
207
259
208
260
## Best practices
209
261
210
-
-**Wait for readiness** - Stream logs to detect when services are ready
262
+
-**Wait for readiness** - Use `ready` option or `waitFor()` to ensure services are fully started before proceeding
263
+
-**Choose the right pattern** - Use `ready` option for simple cases, `waitFor()` for multiple conditions, or `serve()` for servers
211
264
-**Clean up** - Always stop processes when done
212
265
-**Handle failures** - Monitor logs for errors and restart if needed
213
266
-**Use try/finally** - Ensure cleanup happens even on errors
0 commit comments