Run Locally
Run Function Cloud Hosting locally (container-based cloud hosting service is not supported).
Basic Usage
tcb cloudrun run [options]
Command Line Parameters
The supported command line parameters are as follows:
Options:
--runMode <runMode> Operation mode. Optional values: normal (normal function) | agent (functional Agent). Default value: normal
--agentId <agentId> The Agent ID must be provided for debugging in agent mode.
-e, --envId <envId> Environment ID
--port <port> Listening port, defaults to 3000
-w, --watch Whether to enable hot restart mode. If enabled, the service will automatically restart when files change. Defaults to false.
--dry-run Whether to not start the service and only verify that the code can be loaded properly. Defaults to false.
--logDirname <logDirname> Log file directory, defaults to ./logs
--functionsConfigFile <functionsConfigFile> Multi-function configuration file. Defaults to ./cloudbase-functions.json
Environment variable: FUNCTIONS_CONFIG_FILE
--loadAllFunctions Whether to load all functions in the "functionsRoot" directory. Defaults to false
--extendedContext <extendedContext> Used to parse the value of context.extendedContext. "" indicates this feature is disabled. Defaults to null
Example: --extendedContext '{"a":1,"b":2}'
Environment variable: EXTENDED_CONTEXT
--open-debug-panel <openDebugPanel> Whether to open the debug panel. Defaults to 'true'
-h, --help Display command help information
Operation Mode Example
1. normal mode (default)
Normal function mode, suitable for conventional function execution scenarios:
# Basic Usage
tcb cloudrun run -e env-123456
# With Hot Restart
tcb cloudrun run -e env-123456 -w
2. agent mode
Functional Agent mode, requires providing Agent ID for debugging:
# Basic agent mode
tcb cloudrun run --runMode agent --agentId ibot-agent-xxx -e env-123456
# agent mode with hot restart
tcb cloudrun run --runMode agent --agentId ibot-agent-xxx -e env-123456 -w
For more examples, see: Function Samples
Environment Variables
When running locally, create a configuration file named .env.local in the project root directory (note: the filename starts with a dot), and write environment variables in KEY=VALUE format, as shown in the following example:
# .env.local
API_KEY=your_api_key123
After the project is deployed, please configure the environment variables in the management console of this cloud hosting service.