Skip to content
GitHub

Getting Started with Runy SDK

Runy SDK works best in combination with Bun or Deno Javascript runtimes. It can also run on Node.js, but Bun or Deno are recommended for better performance and features.

This guide will be using Bun, but the concepts apply similarly to Deno.

To create a managed Workspace, you need to define a TypeScript file my-workspace.ts using the @runy-dev/core SDK.

#!/usr/bin/env -S bun --watch

import { workspace } from "@runy-dev/core";

const ws = workspace(import.meta);

ws.service("test", (s) => {
  s.autorun();
  s.run(async (ctx) => {
    await ctx.process({
      alias: "server",
      cmd: "python3",
      args: ["-m", "http.server", "8500"],
    });
  });
});

This part of the code defines a workspace with a service named “test”. The service runs a simple HTTP server using Python.

Before running the workspace you need to make your TypeScript file executable. You can do this by running the following command in your terminal:

chmod +x my-workspace.ts

To run the workspace, use the following command:

runy start my-workspace.ts

This command will start the workspace defined in workspace.ts. Once started, Runy will analyze the workspace, start the defined services, and manage their lifecycle.

When you run the runy start command, the following happens:

  1. Runy creates a new workspace my-workspace based on the file name.
  2. It starts a new process inside the workspace, which runs the TypeScript file. The TypeScript is an executable (because of the #!/usr/bin/env -S bun --watch line) that executes the code using Bun.
  3. The @runy-dev/core SDK is imported, which provides the workspace function to define services and manage their lifecycle.
  4. The SDK communicates with the Runy daemon to manage the services defined in the workspace.
Diagram