All Products
Search
Document Center

Function Compute:FAQ about Serverless Devs

Last Updated:Feb 07, 2025

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 should I do if an exception occurs but no error messages are reported when using Serverless Devs?

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 responses are returned, this may indicate an issue with the local Node.js runtime. Reinstall Node.js 14 or a later version.

If the issue persists, join the DingTalk group (group ID: 64970014484) and provide the log file and s.yaml file to the Function Compute developers, who will then help you troubleshoot the issue.

The following figure shows how to obtain the log file.

image.png

What should I do if I can't find functions in the console after deploying a new project?

If you cannot find the functions in the console after the s deploy command finishes running, try the following solutions:

  1. Search for your functions by prefix match. If your project has multiple functions, edit the s.yaml file to make sure that all functionName in the project have the same prefix, which facilitates function searching.

  2. Click the image button to refresh the function list.

image

Note

To manage Serverless Devs projects in Serverless Application Center, submit your projects to the online repository after s init finishes running, and then import applications to Serverless Application Center for management. For more information, see Manage applications. After applications are imported and changes are submitted to the repository, project deployment automatically starts, so you don't need to run the s deploy command.

What should I do if the local configuration conflicts with the online configuration when deploying a project?

  • If the local configuration (that is, the configuration in the s.yaml file) conflicts with the online configuration, Serverless Devs will prompt you to choose between local and online configurations.

    image

  • If you want the local configuration to take effect by default, run the s deploy -y command.

Does Serverless Devs support multi-region deployment?

Yes. The following code provides an example on how to deploy Serverless Devs across multiple regions:

Example for Shell

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

Example for 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 perform local debugging on a function?

  • If your runtime is a built-in runtime of Function Compute, such as a Node.js or Python runtime, 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 or a Custom Container runtime, initiate a server code debugging process as normal.

    Note

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

How do I use the .fcignore file?

Configure a .fcignore file in a specified directory of your code. The .fcignore file is used to specify which files to ignore during the deployment of code packages. For more information, see Use .fcignore.

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 invoke only one of them, 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. During function deployment, 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 locally 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. To solve this issue, 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 command output:

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