Skip to main content

Overview

execd is the execution daemon for OpenSandbox. Built on Beego, it exposes a comprehensive HTTP API that turns external requests into runtime actions: managing Jupyter sessions, streaming code output via Server-Sent Events (SSE), executing shell commands, operating on the sandbox filesystem, and collecting host-side metrics.

Core Features

Unified Runtime Management

  • Translate REST calls into runtime requests handled by pkg/runtime
  • Multiple execution backends: Jupyter, shell, etc.
  • Automatic language detection and routing
  • Pluggable Jupyter server configuration

Jupyter Integration

  • Maintain kernel sessions via pkg/jupyter
  • WebSocket-based real-time communication
  • Stream execution events through SSE
  • Support for multiple language kernels

Command Executor

  • Foreground and background shell commands
  • Proper signal forwarding with process groups
  • Real-time stdout/stderr streaming
  • Context-aware interruption

Filesystem Operations

  • CRUD helpers around the sandbox filesystem
  • Glob-based file search
  • Chunked upload/download with resume support
  • Permission management

Observability

  • Lightweight metrics endpoint (CPU, memory, uptime)
  • Structured streaming logs
  • SSE-based real-time monitoring

Architecture

Directory Structure

Getting Started

Prerequisites

  • Go 1.24+ (as defined in go.mod)
  • Jupyter Server (required for code execution)
  • Docker (optional, for containerized builds)
  • Make (optional, for convenience targets)

Quick Start

1

Clone and Build

2

Start Jupyter Server

3

Run execd

4

Verify

Docker Image Build

Configuration

Command-line Flags

Environment Variables

All flags can be set via environment variables:
Environment variables override defaults but are superseded by explicit CLI flags.

Graceful Shutdown

Controls how long execd keeps SSE responses alive after sending the final chunk:
  • Env: EXECD_API_GRACE_SHUTDOWN (e.g., 500ms, 2s, 1m)
  • Flag: --graceful-shutdown-timeout
  • Default: 1s
Set to 0s to disable the grace period.

API Reference

See the execd API Specification for complete endpoint documentation.

Key Endpoints

Supported Languages

Jupyter-based Execution

Native Executors

Code Execution Example

Execute Python Code

Execute with Session

Filesystem Operations

List Files

Upload File

Download File

Search Files

Observability

Logging

Beego leveled logger with configurable output:
Log Levels (0-7):
  • 0: Emergency
  • 1: Alert
  • 2: Critical
  • 3: Error
  • 4: Warning
  • 5: Notice
  • 6: Info (default)
  • 7: Debug

Metrics

Snapshot:
Response:
Real-time Monitoring (SSE, 1s cadence):

Performance Benchmarks

Typical Latency (localhost)

Resource Usage (idle)

  • Memory: ~50MB
  • CPU: < 1%
  • Goroutines: ~15

Scalability

  • 100+ concurrent SSE connections
  • File operations scale linearly with file size
  • Jupyter sessions are stateful and need dedicated resources

Testing

Unit Tests

Integration Tests

Integration tests requiring a real Jupyter Server are skipped by default:

Manual Testing Workflow

1

Start Jupyter

2

Start execd

3

Execute Code

Development

See DEVELOPMENT.md for detailed guidelines.

Code Quality

Support