tcb cloudrun run
Run and debug a function-type CloudBase Run service locally. Container-type services cannot run locally.
Usage
tcb cloudrun run -e <envId> [options]
# Agent mode
tcb cloudrun run --runMode agent --agentId <agentId> -e <envId>
Parameters
| Parameter | Required | Description | Default |
|---|---|---|---|
-e, --env-id <envId> | Yes | Environment ID | — |
--runMode <mode> | No | Run mode: normal / agent | normal |
--agentId <agentId> | Conditional | Agent ID, required in agent mode | — |
--port <port> | No | Listening port | 3000 |
-w, --watch | No | Restart the service when files change | false |
--dry-run | No | Validate that the code loads, without starting the service | false |
--logDirname <dir> | No | Log directory, resolved against the current directory | ./logs |
--functionsConfigFile <file> | No | Multi-function definition file, resolved against the current directory | ./cloudbase-functions.json |
--loadAllFunctions | No | Load every function under the functionsRoot directory | false |
--extendedContext <json> | No | JSON string used to resolve context.extendedContext, for example '{"a":1,"b":2}' | — |
--open-debug-panel | No | Whether to open the debug panel | true |
Examples
# Normal mode on the default port 3000
tcb cloudrun run -e env-123456
# Specific port
tcb cloudrun run -e env-123456 --port 8080
# Watch mode
tcb cloudrun run -e env-123456 -w
# Validate the code only
tcb cloudrun run -e env-123456 --dry-run
# Load every function under the target directory
tcb cloudrun run -e env-123456 --loadAllFunctions
Agent mode:
# Debug in agent mode
tcb cloudrun run --runMode agent --agentId ibot-agent-xxx -e env-123456
# Agent mode with watch
tcb cloudrun run --runMode agent --agentId ibot-agent-xxx -e env-123456 -w
# Agent mode on a specific port
tcb cloudrun run --runMode agent --agentId ibot-agent-xxx -e env-123456 --port 8080
Environment variables
Create a .env.local file in the project directory (the current directory unless --cwd is given) with KEY=VALUE pairs:
# .env.local
API_KEY=your_api_key123
DATABASE_URL=mysql://localhost:3306/db
These variables only apply to local runs; after deployment configure them in the console.
Notes
- Function-type services only, container-type services are not supported
- Agent mode requires an existing Agent and its Agent ID
- The command changes into the project directory before starting, while paths passed on the command line still resolve against the current directory
- Writing functions: see the function examples