All Products
Search
Document Center

Function Compute:FAQ about Serverless Devs

Last Updated:Nov 03, 2023

This topic provides answers to commonly asked questions about Serverless Devs.

How do I configure the s.yaml file?

For more information about YAML specifications, see YAML specifications.

What do I do if an exception occurs but no error message is reported when I use Serverless Devs?

You can perform the following steps to troubleshoot the issue:

  1. Run the npm install @serverless-devs/s -g command to update Serverless Devs.

  2. Run the s clean --all command to delete redundant files.

  3. Run the rm -rf .s command to remove the .s file from the directory.

  4. Run the s -v command to view the version of Serverless Devs.

    If no response is returned after you run the command, the local Node.js runtime may be abnormal. You must reinstall Node.js 12 or a later version.

If the issue persists, join the DingTalk group 11721331 to contact technical support. Provide the {s-home}/logs/{TraceId}.log log file and the s.yaml file to facilitate troubleshooting.

The following figure provides an example on how to obtain {s-home} and {TraceId}.checks-s-home

What do I do if I want to use local configurations when I deploy the code?

You can select use-local when you run the s deploy command, or run the s deploy -y --use-local command.

Does Serverless Devs support multi-region deployment?

Yes, Serverless Devs supports multi-region deployment. For more information, see Multi-region deployment of Serverless Devs.

How do I perform local debugging on a function?

  • If your runtime is not a custom runtime but a built-in runtime of Function Compute, such as Node.js or Python, we recommend that you use the local invocation method of Serverless Devs for debugging. For more information, see Local commands.

  • If your runtime is a custom runtime, you can start a server code debugging process based on common development practices.

    Note

    For custom runtimes, you can run the s local invoke command to invoke your functions locally. However, breakpoint debugging is not supported.

How do I use the .fcignore file?

When you deploy a large code package, you can use the .fcignore file to exclude specific project dependencies that are uploaded to Apsara File Storage NAS. Then, you can deploy the project online. For more information, see Common tips.

How do I specify the function to deploy and invoke if multiple functions are defined in the s.yaml file?

In the s.yaml file, a service may contain multiple functions. If you want to deploy or invoke only one of the functions, you can specify the function name when you run the following command: s deploy, s local start, or s local invoke. In the s.yaml example file shown in the following figure, only the helloworld function is deployed after you run the s helloworld deploy function.

muti-functions

What do I do if the "connect ENOENT /var/run/docker.sock" error is reported when I run the s local or s build command?

Error message

Project xxx failed to execute:

ERROR:

connect ENOENT /var/run/docker.sock

Solution

If Docker commands can be run as expected on an on-premises machine but the s local or s build command cannot be run in Serverless Devs, perform the following steps to resolve the issue:

  1. Check whether the /var/run/docker.sock file exists.

    1. Run the following command to check whether the file exists. If the file exists, skip the following step. If the file does not exist, perform the following step.

      ll /var/run/docker.sock
    2. Configure a symbolic link that points to the /var/run directory.

      ll ~/.docker/run/docker.sock
      ln -s ~/.docker/run/docker.sock  /var/run/docker.sock
  2. Check whether the Docker client is started.

    To run the s local or s build command in Serverless Devs, you must start the Docker client. Make sure that the Docker client is started.

How do I use Node.js 18 in Serverless Application Center or Serverless Devs?

In web scenarios, most users use custom runtimes. However, the built-in Node.js, Python, and PHP versions may be unable to meet their requirements. In this case, if you want to use Node.js 18, use the following method:

We recommend that you create a function that runs in a custom runtime in the console, select Node.js 18 for Runtime, and then export the configuration of the function on the function details page. The layers variable in YAML is used to mount the common layer for Node.js 18. The PATH variable in YAML is used to set Node.js 18 as the default version.

service:
	internetAccess: true
  name: test-service
function:
	handler: index.handler
  timeout: 60
  diskSize: 512
  caPort: 3000
  layers:
  	- acs:fc:cn-hangzhou:official:layers/Nodejs18/versions/1
  customRuntimeConfig:
  	command:
    	- node
      - server.js
  runtime: custom.debian10
  environmentVariables:
  	PATH: /opt/nodejs18/bin:/usr/local/bin/...
    NODE_PATH: /opt/nodejs/node_modules
  ...

If you are using the features provided in Serverless Application Center, the layer configurations cannot take effect during the build process. Therefore, you need to run the export PATH command to specify that Node.js 18 is used during the build process and then run npm install and npm run build. For more information, see Upgrade the runtime of a pipeline.