All Products
Search
Document Center

Function Compute: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 information about the YAML syntax, see YAML syntax.

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/s3 -g command to upgrade Serverless Devs.

  2. Run the s clean --all command to remove all components and redundant files.

  3. 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 14 or a later version.

If the issue persists, join the DingTalk group 11721331 and provide the log file and the s.yaml file to Function Compute developers to troubleshoot the issue.

The following figure describes how to obtain the log file.

image.png

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

If you want to use local configurations when you deploy code, run the s deploy -y command.

Does Serverless Devs support multi-region deployment?

Yes, Serverless Devs supports multi-region deployment. The following code provides an example on how to deploy Serverless Devs in multiple regions:

Shell script

```bash
#!/bin/bash
regions=("cn-hangzhou" "ap-southeast-1")
for r in ${regions[@]}
do
  export REGION=$r
  s deploy -y
done
```

s.yaml

```yaml
edition: 3.0.0
name: hello-world-app
access: "default"
resources:
  hello_world:
    component: fc3
    props:
      region: ${env('REGION')}
      functionName: "start-nodejs-im1g"
      description: 'hello world by serverless devs'
      runtime: "nodejs14"
      code: ./code
      handler: index.handler
      memorySize: 128
      timeout: 30
```

How do I debug a function on an on-premises machine?

  • If you use a built-in runtime of Function Compute, such as Node.js and Python, we recommend that you use Serverless Devs to debug a function on an on-premises machine. For more information, see Local commands.

  • If you use a custom runtime or a custom container runtime, you can start a server code debugging process based on common practices.

    Note

    You can run the s local invoke command to invoke your function on an on-premises machine. However, breakpoint debugging is not supported.

How do I use the .fcignore file?

You can configure a .fcignore file in the specified directory of the code. The .fcignore file is used to ignore the related files or package folders into a ZIP file and then upload the file to the function code. For more information, see Use the .fcignore file.

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

In the s.yaml file, a service may include multiple functions. If you want to deploy or call only one of the functions, you can specify the function name when you run the s deploy, s info, or s local invoke command. In the following example, multiple functions are included in the s.yaml file of a service. When you deploy functions, you can run the s helloworld1 deploy command to deploy only the helloworld1 function.

```yaml
edition: 3.0.0
name: hello-world-app
access: "default"

resources:
  hello_world1:
    component: fc3
    props:
      region: cn-huhehaote       
      functionName: "hello_world1"
      description: 'hello world1 by serverless devs'
      runtime: "nodejs14"
      code: ./code
      handler: index.handler

  hello_world2:
    component: fc3
    props:
      region: cn-huhehaote       
      functionName: "hello_world2"
      description: 'hello world2 by serverless devs'
      runtime: "nodejs14"
      code: ./code
      handler: index.handler
```

How do I use Serverless Devs to build and debug a function on an on-premises machine based on Podman?

When you use Serverless Devs to build or debug a function on an on-premises machine based on Podman, an error Failed to start docker, xxx is returned. In this case, you can create a symbolic link that points to the Podman directory for the Docker directory and then build or debug the function. The following items describe how to create a symbolic link:

  1. Query the path of the Podman executable file.

    which podman

    In this example, the path of the Podman executable file is /usr/bin/podman.

  2. Configure a symbolic link.

    ln -s /usr/bin/podman /usr/bin/docker
  3. Query whether the symbolic link takes effect.

    ls -lh /usr/bin/docker

    Expected output:

    lrwxrwxrwx 1 root root 15 Jan  5 09:30 /usr/bin/docker -> /usr/bin/podman