Skip to content

devlanes is in beta and not ready for production use.Report an issue

Run a service in its runtime

Use this guide when you put a Node, Bun, Deno, Python, Rust, Go or Java service on devlanes and want the lines its code and command need.

Each service gets its port in PORT and the loopback address in HOST. Read both where the server starts listening.

Node

const port = Number(process.env.PORT ?? 3000);
server.listen(port, process.env.HOST ?? "127.0.0.1");

Bun

Bun.serve({
port: Number(process.env.PORT ?? 3000),
hostname: process.env.HOST ?? "127.0.0.1",
fetch,
});

Deno

Deno.serve({
port: Number(Deno.env.get("PORT") ?? 8000),
hostname: Deno.env.get("HOST") ?? "127.0.0.1",
}, handler);

The task has to allow reading the two variables:

deno.json
{ "tasks": { "dev": "deno run --watch --allow-net --allow-env=PORT,HOST main.ts" } }

Python

devlanes.yaml
services:
api:
run: uv run uvicorn acme.main:app --host 127.0.0.1 --port ${{ self.port }} --reload

Rust

let port = std::env::var("PORT").unwrap_or_else(|_| "3000".into());
let host = std::env::var("HOST").unwrap_or_else(|_| "127.0.0.1".into());
let listener = tokio::net::TcpListener::bind(format!("{host}:{port}")).await?;

Go

host := cmp.Or(os.Getenv("HOST"), "127.0.0.1")
port := cmp.Or(os.Getenv("PORT"), "8080")
log.Fatal(http.ListenAndServe(net.JoinHostPort(host, port), mux))

Java

int port = Integer.parseInt(System.getenv().getOrDefault("PORT", "8080"));
String host = System.getenv().getOrDefault("HOST", "127.0.0.1");

Spring Boot and Quarkus take the port from a preset instead, as Run Spring Boot and Quarkus shows.

devlanes leaves watching files to the runtime, so use its watch mode in the command:

  • Node: node --watch, tsx watch or nodemon.
  • Bun: bun --watch.
  • Deno: deno run --watch, as in the task above.
  • Python: uvicorn’s --reload.
  • Java: Quarkus dev mode (quarkus:dev, quarkusDev), or Spring Boot DevTools, which restarts the app when your IDE or a mvn compile writes new classes.
  • Go: air, building into the lane’s data folder so two lanes never run one binary. On Windows, end both paths in api.exe.
devlanes.yaml
services:
api:
run:
- air
- --build.cmd
- go build -o "${{ lane.data_path }}/api" ./cmd/api
- --build.entrypoint
- ${{ lane.data_path }}/api

A Rust service, a Go service run with go run, or a Java service without dev mode or DevTools rebuilds when you restart it:

Terminal window
$ devlanes restart api

devlanes tells the runtime from the script’s file or the service’s folder. A folder with a package.json counts as Node, and one with a Cargo.toml as Rust, so set the runtime on another service there:

devlanes.yaml
services:
api:
platform: python

A service counts as Java when its script is in, or its folder holds, a pom.xml or Gradle file. One that runs java -jar from a folder without either needs platform: java.

If a service calls another hostname over HTTPS

Section titled “If a service calls another hostname over HTTPS”

devlanes points these runtimes at its CA, so remove any setting that turns certificate checks off. Trust the devlanes CA covers other runtimes.

Go programs built without cgo look lane hostnames up in DNS; Fix programs that cannot resolve *.localhost makes them resolve.