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
for await (const log of parseSSEStream<LogEvent>(dbLogs)) {
148
-
if (log.data.includes('Ready to accept connections')) {
149
-
break;
150
-
}
160
+
if (log.data.includes('Ready to accept connections')) {
161
+
break;
162
+
}
151
163
}
152
164
153
165
// Now start API server (depends on database)
154
166
const api = await sandbox.startProcess('node api-server.js', {
155
-
env: { DATABASE_URL: 'redis://localhost:6379' }
167
+
env: { DATABASE_URL: 'redis://localhost:6379' }
156
168
});
157
169
158
170
console.log('All services running');
171
+
159
172
```
160
173
</TypeScriptExample>
161
174
162
175
## Keep containers alive for long-running processes
163
176
164
-
By default, containers automatically shut down after 3 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:
177
+
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:
165
178
166
179
<TypeScriptExample>
167
180
```
181
+
168
182
import { getSandbox, parseSSEStream, type LogEvent } from '@cloudflare/sandbox';
169
183
170
184
export default {
@@ -194,8 +208,10 @@ export default {
194
208
// Important: Must explicitly destroy when done
195
209
await sandbox.destroy();
196
210
}
197
-
}
211
+
212
+
}
198
213
};
214
+
199
215
```
200
216
</TypeScriptExample>
201
217
@@ -219,14 +235,16 @@ Check logs to see why:
219
235
220
236
<TypeScriptExample>
221
237
```
238
+
222
239
const process = await sandbox.startProcess('node server.js');
223
240
await new Promise(resolve => setTimeout(resolve, 1000));
0 commit comments