All Products
Search
Document Center

Function Compute (2.0):FAQ about Serverless Devs

Last Updated:Mar 15, 2024

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 commands, 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 (ID: 11721331) to contact technical support and provide the {s-home}/logs/{TraceId}.log file and the s.yaml file for 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 simply 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, such as Node.js or Python, in Function Compute, 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 upload dependencies in a project to an Apsara File Storage NAS (NAS) file system to deploy a large code package, you can use the .fcignore file to exclude specific files. For more information, see Common tips.

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

In an 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. The following figure shows a sample s.yaml file. In the 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

Sample error message:

Project xxx failed to execute:

ERROR:

connect ENOENT /var/run/docker.sock

Solution

If you can run Docker commands as expected on an on-premises machine but cannot run the s local or s build command 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 not meet their business 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 the Runtime parameter, and then export the configurations 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, to use Node.js 18 during the build process, you need to run the export PATH command to specify that Node.js 18 is used and then run the npm install and npm run build commands. For more information, see Upgrade the runtime of a pipeline.

Why am I unable to access an application that is deployed by using Serverless Devs? Is it because the bound domain name is deleted?

You may have used the ****.devsapp.net domain name. This domain name is provided by the Serverless Devs community for learning and testing. Serverless Devs is the official sandbox project of the Cloud Native Computing Foundation (CNCF). The Serverless Devs community dial tests the domain name from time to time and reclaims the domain name 30 days after the domain name is issued. We recommend that you bind a custom domain name to your application for better experience.