Serverless Cloud Framework supports the development mode (dev
mode). For projects in development mode, you can write their code and develop and debug them more easily, as you can continuously focus on the process from development to debugging while minimizing the interruptions caused by other tasks such as packaging and update.
Under a project, you can run scf dev
to enter the development mode as shown below:
Currently,
scf dev
is supported by only the Node.js 10 & 12.16 runtime environment.
$ scf dev
serverless-cloud-framework
Dev Mode - Watching your Component for changes and enabling streaming logs, if supported...
Debugging listening on ws://127.0.0.1:9222.
For help see https://nodejs.org/en/docs/inspector.
Please open chorme, and visit chrome://inspect, click [Open dedicated DevTools for Node] to debug your code.
--------------------- The realtime log ---------------------
17:13:38 - express-api-demo - deployment
region: ap-guangzhou
apigw:
serviceId: service-b77xtixx
subDomain: service-b77xtixx-12539702xx.gz.apigw.tencentcs.com
environment: release
url: http://service-b77xtixx-12539702xx.gz.apigw.tencentcs.com/release/
scf:
functionName: express_component_6r6xkh60k
runtime: Nodejs10.15
namespace: default
express-api-demo › Watching
After you enter the development mode, the Serverless tool will output the deployed content and start continuous file monitoring. When a code file is updated, it will be automatically deployed again to sync the local file to the cloud.
You can press Ctrl+C
to exit the development mode, and the following result will be returned:
express-api-demo › Disabling Dev Mode & Closing ...
express-api-demo › Dev Mode Closed
You can enable in-cloud debugging for projects whose runtime environment is Node.js 10. You can use a debugging tool such as Chrome DevTools or VS Code Debugger to connect to the remote environment for debugging.
SCF in-cloud debugging is currently in beta test. You are recommended to try it out and share your questions and suggestions with us.
Before using SCF in-cloud debugging, you need to note the following:
When you enter the development mode, if the project is a function whose runtime environment is Node.js 10 or above, in-cloud debugging will be automatically enabled and debugging information will be output.
For example, when you enable the development mode, if the output result contains information similar to the following content, in-cloud debugging has been enabled for this project.
Debugging listening on ws://127.0.0.1:9222.
For help see https://nodejs.org/en/docs/inspector.
Please open chorme, and visit chrome://inspect, click [Open dedicated DevTools for Node] to debug your code.
The following steps are used as an example to describe how to use DevTools in Chrome to connect to a remote environment for debugging:
chrome://inspect/
in the address bar to access it.localhost:9229
or localhost:9222
exists in "Configure" under "Devices", which corresponds to the output after in-cloud debugging is enabled./var/user/
directory.When you exit the development mode, in-cloud debugging will be disabled automatically.
Was this page helpful?