Skip to main content

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​

ParameterRequiredDescriptionDefault
-e, --env-id <envId>YesEnvironment ID—
--runMode <mode>NoRun mode: normal / agentnormal
--agentId <agentId>ConditionalAgent ID, required in agent mode—
--port <port>NoListening port3000
-w, --watchNoRestart the service when files changefalse
--dry-runNoValidate that the code loads, without starting the servicefalse
--logDirname <dir>NoLog directory, resolved against the current directory./logs
--functionsConfigFile <file>NoMulti-function definition file, resolved against the current directory./cloudbase-functions.json
--loadAllFunctionsNoLoad every function under the functionsRoot directoryfalse
--extendedContext <json>NoJSON string used to resolve context.extendedContext, for example '{"a":1,"b":2}'—
--open-debug-panelNoWhether to open the debug paneltrue

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