Services and observability
Services keep named processes running in the sandbox. The SDK can inspect their state and output alongside ports, metrics, and captured mail.
Run a service
Redis is available as a built-in service. You can also run a named command as a service:
await sandbox.services.run('redis');
await sandbox.services.run('queue', 'php artisan queue:work');
const services = await sandbox.services.list();
console.log(services);
Stop a service by name:
await sandbox.services.stop('queue');
Read service logs
const recent = await sandbox.services.logs('redis', { tail: 50 });
console.log(recent);
const stream = sandbox.services.logs('queue', {
follow: true,
tail: 25,
});
for await (const line of stream) {
console.log(line);
}
Inspect the runtime
const ports = await sandbox.runtime.ports.list();
const metrics = await sandbox.runtime.metrics.current();
console.log(ports, metrics);
Realtime clients can also watch ports and metrics and follow combined runtime logs.
Capture application mail
const state = await sandbox.mail.status();
if (!state.enabled) {
await sandbox.mail.enable();
}
const messages = await sandbox.mail.list();
Use the returned SMTP state to configure the application. Captured mail remains inside the sandbox workflow and is not delivered to real recipients.