Skip to content

Services

Run a long-running server on a stable host.

A service is a server that runs all the time and answers requests on a stable host. Use it for APIs, web apps and anything else that is not tied to a session.

Not available yet.

Not available yet.

Not available yet.

import { Sutra } from "@mistrive/sutra";

const sutra = new Sutra({
  baseUrl: "https://anchor.jgcp.mistrivedev.com",
});

const service = await sutra.services.create({
  id: "orders-api",
  revision: {
    // Requests to the service host go to this port in the sandbox.
    port: 8080,
    sandbox: {
      source: { image: "ghcr.io/acme/orders-api:1.0" },
      resources: { milliCpus: 1000, memoryBytes: 1024 ** 3, diskBytes: 2 * 1024 ** 3 },
      env: { LOG_LEVEL: "info" },
    },
    processes: { web: { argv: ["/app/server"] } },
  },
});

console.log(service.uri, service.activeRevision);
from mistrive.sutra import Sutra

sutra = Sutra(
    base_url="https://anchor.jgcp.mistrivedev.com",
)

service = sutra.services.create(
    id="orders-api",
    revision={
        # Requests to the service host go to this port in the sandbox.
        "port": 8080,
        "sandbox": {
            "source": {"image": "ghcr.io/acme/orders-api:1.0"},
            "resources": {"milli_cpus": 1000, "memory_bytes": 1024**3, "disk_bytes": 2 * 1024**3},
            "env": {"LOG_LEVEL": "info"},
        },
        "processes": {"web": {"argv": ["/app/server"]}},
    },
)

print(service.uri, service.active_revision)
#!/usr/bin/env bash
set -euo pipefail

# Assumes you ran `sutra auth login` (see the Quickstart).
# Requests to the service host go to port 8080 in the sandbox.
sutra services create orders-api \
  --image ghcr.io/acme/orders-api:1.0 \
  --port 8080 \
  --env LOG_LEVEL=info \
  -- /app/server

How a service runs

A service runs in a sandbox that it owns. The sandbox appears when you list sandboxes, with owner set to the service, and you can run processes in it and read its files like any other sandbox. Requests to the service’s host, in uri, go to the port named in the revision.

A service runs one sandbox. Running more than one, with requests spread across them, comes later.

Shared with agents

Services and agents use the same parts:

  • A revision holds the definition, and the service runs its active revision.
  • Instances are ordinary sandboxes owned by the workload.
  • Each has its own workload identity and can use integrations.

The difference is how requests are routed. A service sends every request to its one host. An agent gives each session its own sandbox.

Type to search…

↑↓ navigate↵ selectEsc close